ttk

Tkinter look (theme) in Linux

删除回忆录丶 提交于 2019-12-04 08:00:54
问题 I know that Tkinter is not so modern, not so cool and maybe better to use PyQt or etc. But it is interesting for me can Tkinter looks not so ugly in Ubuntu (Linux). Looks that brew version (in OS X) of python's Tkinter compiled with built-in theme and looks good: But Ubuntu's Tkinter makes me cry: I've read that for good theme I need to use ttk, but I dont know exactly how. My code looks as follow: from Tkinter import * class App(): def __init__(self, master): frame = Frame(master) frame.pack

Is there an in depth ttk styling guide available? [closed]

≡放荡痞女 提交于 2019-12-04 07:25:12
So I've begun dabbling with Tkinter as of late, and I have it in my head to create what is essentially an application for storytelling. Ultimately, I'd like stylize most every widget used to conform with some overall aesthetic of my design. Originally, I though I'd have to create most all of my application within tkinter's Canvas widget, as only it allowed for the level of customization I wanted. To my embarrassment, I have only just now stumbled across ttk and its ttk.Style methods. As working with the Canvas widget will require me to reinvent some wheels: getting images to act as if they

ttk.Separator set the length/width

≡放荡痞女 提交于 2019-12-04 04:19:05
问题 How to set/change the length/width of a ttk.Separator object in Tkinter? ttk.Separator(self, orient='horizontal').grid(column=0, row=0, columnspan=2, sticky='ew') It seems that columnspan tries to do the job, but when you have multiple separators with the same columnspan, they appear to have different lengths - any idea why? Here is a simple quick ad-hoc "dirty" test example: import ttk from Tkinter import * class myTestFrame(Frame): def __init__(self): Frame.__init__(self) self.master.title(

how to know all style options of a ttk widget

醉酒当歌 提交于 2019-12-04 03:42:35
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 following s = ttk.Style() s.configure('TLabelframe', foreground='red') But this doesn't work, the right

When to use pack or grid layouts in tkinter?

為{幸葍}努か 提交于 2019-12-03 10:52:02
问题 Are there any best practice tips regarding when one should use pack vs. grid for their layouts? From what I've been reading via google, the concencus seems to be that grid can handle any pack scenario but not vice-versa. To start the conversation, it appears that one use case that favors grid vs. pack is when one wants to show/hide widgets. 回答1: Neither is intrinsically better than the other. Each have strengths and weaknesses. Learn what those are and the choice of which to use becomes

Expandable and contracting frame in Tkinter

两盒软妹~` 提交于 2019-12-03 09:11:31
问题 Does anyone know if there is already a widget/class to handle expanding/contracting a frame based on a toggled button (checkbutton) in tkinter/ttk? This question stems from my attempt to clean up a cluttered gui that has lots of options categorized by specific actions. I would like something along the lines of: example found on google However instead of just text, allow for buttons, entries, any of tkinter's widgets. If this doesn't already exist, would it be possible/useful to create a class

Finding the currently selected tab of Ttk Notebook

∥☆過路亽.° 提交于 2019-12-03 06:25:53
I have a Ttk Notebook widget containing 8 Frames - so, 8 tabs. Each frame contains a Text widget. I have a button outside the Notebook widget, and I want to insert text into the current tabs Text widget when this button is pressed. This would seem to require working out which widget in the Notebook is currently selected, but I can't seem to find how to do this. How would I find the currently selected tab? Alternatively, how can I implement what I want to? If it helps, here's the code for my notebook: self.nb = Notebook(master) self.nb.pack(fill='both', expand='yes', padx=10, pady=10) self

When to use pack or grid layouts in tkinter?

扶醉桌前 提交于 2019-12-03 02:26:33
Are there any best practice tips regarding when one should use pack vs. grid for their layouts? From what I've been reading via google, the concencus seems to be that grid can handle any pack scenario but not vice-versa. To start the conversation, it appears that one use case that favors grid vs. pack is when one wants to show/hide widgets. Neither is intrinsically better than the other. Each have strengths and weaknesses. Learn what those are and the choice of which to use becomes obvious. grid is considerably easier to use if you need to lay things out in a grid. pack is generally easier to

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

孤者浪人 提交于 2019-12-03 00:43:43
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 Answered my own question. I Finally found an example that helped, and got it to work with the following code: #update

Expandable and contracting frame in Tkinter

十年热恋 提交于 2019-12-03 00:41:55
Does anyone know if there is already a widget/class to handle expanding/contracting a frame based on a toggled button (checkbutton) in tkinter/ttk? This question stems from my attempt to clean up a cluttered gui that has lots of options categorized by specific actions. I would like something along the lines of: example found on google However instead of just text, allow for buttons, entries, any of tkinter's widgets. If this doesn't already exist, would it be possible/useful to create a class that inherits the tkinter Frame: import tkinter as tk import ttk class toggledFrame(tk.Frame): def _