ttk

Python 2.7 - ttk module seemingly not working in Windows 8.1

核能气质少年 提交于 2019-12-06 01:15:16
My application's GUI is Tkinter based and it is quite functional. I have been trying to use ttk to make it look more modern. I use Python 2.7 in Windows 8.1. Importing ttk goes without error and coding including ttk in the script runs without error. However, the resulting interface looks almost same as the one done only with Tkinter . This is especially true for the buttons. I tried different ttk styles and they almost look same or some worse than Tkinter-only based interface. Tkversion in my system is 8.5. I have been using ttk that comes as part of Python 2.7 itself. I attempted installing

how to know all style options of a ttk widget

时光毁灭记忆、已成空白 提交于 2019-12-05 20:28:51
问题 This problem nearly makes me craze. I am a new beginner and without knowledge of tck/tk. I have done carefully search on the internet but haven't found a good solution. For example, I created a label frame using import tkinter as tk from tkinter import ttk newBT = ttk.LabelFrame(width=100, height=100) Then I need to set the frame style. There is foreground for tk.LabelFrame . However, I didn't find such style option for ttk.LabelFrame on NMT and tck/tk reference. Then I have to guess, like

How can I match background colors for a Frame in a Notebook for ttk/Tkinter on a Mac?

↘锁芯ラ 提交于 2019-12-05 17:37:38
While working on a Tkinter + ttk based GUI on my Mac, I noticed a problem with background colors and the Notebook widget. When adding a ttk.Frame as a ttk.Notebook tab, the displayed background of the frame does not match the 'inset' background for the notebook tab. How can I make the ttk.Frame match the surrounding background color, without hard-coding a value that will look weird for non-Mac users? I read a few SO answers suggesting custom styles, but it's unclear how to query for the parent widget's background color in this situation. As far as I can tell, they're all the same! >>> ttk

Padding specified in style ignored by Ttk Frame

核能气质少年 提交于 2019-12-05 16:13:05
The following code works as expected, presenting a red background button (with lots of padding) in a green background frame (also with lots of padding). Note that Frame padding is specified both in the Style statement and the ttk.Frame initialization. import ttk import Tkinter root = Tkinter.Tk() ttk.Style().configure("TFrame", background="#0c0", padding=60) ttk.Style().configure("TButton", background="#c00", padding=20) frame = ttk.Frame(root, padding=60) frame.pack() btn = ttk.Button(frame, text="Button") btn.pack() root.mainloop() Now, however, remove the 'padding=60' line from the Frame

Create resizable/multiline Tkinter/ttk Labels with word wrap

你说的曾经没有我的故事 提交于 2019-12-05 10:29:15
Is it possible to create a multi-line label with word wrap that resizes in sync with the width of its parent? In other words the wordwrap behavior of Notepad as you change the width of the NotePad window. The use case is a dialog that needs to present a block of multi-line text (instructions) in its entirety without having the text clipped or resorting to scrollbars. The parent container will have enough vertical space to accomodate narrow widths. I've been experimenting with Tkinter Label and Message widgets and the ttk Label widget without success. It seems that I need to hard code a pixel

Create new ttk widget from tkinter

青春壹個敷衍的年華 提交于 2019-12-05 08:52:21
I'm actually trying to create ttk.Spinbox from tkinter.Spinbox . I can manipulate codes below like ttk.Scrollbar pattern. tkinter.Spinbox button gives an old look for my GUI that is why i want to ttk.Spinbox . Edit: I am using Python 3.4 on Windows 7 OS. I need a themed Spinbox widget. ttk.__init__ file has not Spinbox class/module. So, I open that file and wrote codes just like Scrollbar class given below. class Scrollbar(Widget, tkinter.Scrollbar): """Ttk Scrollbar controls the viewport of a scrollable widget.""" def __init__(self, master=None, **kw): """Construct a Ttk Scrollbar with parent

python ttk treeview: how to select and set focus on a row?

倖福魔咒の 提交于 2019-12-05 08:49:11
I have a ttk.Treeview widget with some rows of data. How do I set the focus to and select (highlight) a specified item? tree.focus_set() does nothing tree.selection_set(0) complains that: Item 0 not found, although the widget is plainly populated with more than zero items. Trying item 1 does no better. EDIT: to select an item, find its id, then use tree.selection_set(id). Neither tree.focus(id) nor tree.focus_set(id) appears to do anything. Cat Get the id of treeview item you want to highlight/select child_id = tree.get_children()[-1] # for instance the last element in tuple To highlight the

How to edit the style of a heading in Treeview (Python ttk)

荒凉一梦 提交于 2019-12-05 03:06:16
I am trying to use ttk.Treeview to make a sortable table (as per Does tkinter have a table widget? and https://www.daniweb.com/software-development/python/threads/350266/creating-table-in-python ). Getting it to work is easy, but I'm having some issues with the styling. The default style for the Treeview heading is black text on a white background, which is fine. However, in my code I'm using: ttk.Style().configure(".", font=('Helvetica', 8), foreground="white") to format my GUI. This overarching style also affects the heading of the Treeview widget. Because the default heading background is

ttk: how to make a frame look like a labelframe?

限于喜欢 提交于 2019-12-04 11:36:44
Python ttk gui creating is easy and has mostly native look and feel (win7). I am having a slight problem, though: I would like to have a frame that looks like ttk.LabelFrame but without label. Just omitting the text option will leave an ugly gap. Also I can not get the ttk.Frame border to look like LabelFrame. Is there an elegant way of doing this? Bonus karma if this works on all/most windows versions above xp. Maybe it works with styles but the style LabelFrame properties seem mostly empty (style.element_options("border.relief")). Maybe I am looking in the wrong place. edit: try: # python 3

How to update values to the listbox under Combobox in ttk Python33

空扰寡人 提交于 2019-12-04 08:44:59
问题 When I create the Combobox, it has no items in the list. Now when I click on the dropdown button a function is called (via the postcommand option), but once in my function I don't know how to set the values in the listbox of the Combobox. Code something like this: #update list upon drop down self.cbox = Combobox(self, width = 10, postcommand = self.updtcblist) def updtcblist(self): list = self.getPortLst() self.cbox.getlistbox.set(list) #getlistbox doesn't work Thanks, Harvey 回答1: Answered my