ttk

Python : Display a Dict of Dicts using a UI Tree for the keys and any other widget for the values

天涯浪子 提交于 2019-12-02 13:52:01
问题 I have three dicts, one providing a list of all the available options, and two providing a subset of choices (one set for defaults and one for user choices). I get the three dicts using python's built in JSON parser. I want display, in a UI, a tree on the left that is based on the keys in the dicts, on the right I would like to display either a combobox, a button, a listbox or some other appropriate widget to manipulate the data for that key. I need the tree since I'm really working with a

How can I change the size of tab caption box and font of ttk notebook tabs?

走远了吗. 提交于 2019-12-02 09:45:19
I want to change the font, width and height of a tab caption in ttk.notebook python 3x by below code, i can just change the width of tab caption box text=f'{"frame 1": ^30s} but how i can change the font of "frame 1" and also the height of tab caption box? import tkinter as tk from tkinter import ttk root = tk.Tk() notebook = ttk.Notebook(root) f1 = tk.Frame(notebook, bg='red', width=200, height=200) f2 = tk.Frame(notebook, bg='blue', width=200, height=200) notebook.add(f1, text=f'{"frame 1": ^30s}') notebook.add(f2, text=f'{"frame 2 longer": ^30s}') notebook.grid(row=0, column=0, sticky="nw")

tkinter.ttk.Treeview root node icon/image does not appear

醉酒当歌 提交于 2019-12-02 08:03:00
Problem: I am not able to get an icon image to appear next to the root node in tkinter.ttk.Treeview. Below is a test code I used. It executed w/o errors but image did not appear on the left of root node. I have tried using the full path name of the image file but that did not work. Also, I have tried using PIL.ImageTk.PhotoImage to open the image file but that did not work either. Instead an error as shown below appeared. Question: How do I get an icon image to appear on the left of the root node (or any node) of tkinter.ttk.Treeview? Test Code: import os import tkinter as tk import tkinter

Python : Display a Dict of Dicts using a UI Tree for the keys and any other widget for the values

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-02 07:08:05
I have three dicts, one providing a list of all the available options, and two providing a subset of choices (one set for defaults and one for user choices). I get the three dicts using python's built in JSON parser. I want display, in a UI, a tree on the left that is based on the keys in the dicts, on the right I would like to display either a combobox, a button, a listbox or some other appropriate widget to manipulate the data for that key. I need the tree since I'm really working with a dict of dicts and I want to allow folding. So far I have looked into tkinter, tkinter's ttk and tix

How do you overlap widgets/frames in python tkinter?

≡放荡痞女 提交于 2019-12-01 17:51:44
I was wondering if this is even possible. My goal is to have a small white box in the bottom right hand corner, on top of a larger text field. The white box will be used as an "info box" while the person scrolls through the text inside of the text field. When I say "text field" I mean Text from tkinter. The way to place one widget on top of other widgets is to use the place geometry manager. You can specify an x/y coordinate relative to some other widget, as well as to specify either absolute or relative widths and heights. The effbot site has a decent writeup on the place geometry manager:

Trying to add an image that functions like a button, but this error, image “pyimage2” doesn't exist, pops up

吃可爱长大的小学妹 提交于 2019-12-01 11:22:41
I already have a set of code that is similarly formatted as the one below, and that seems to work. But somehow, the image for this one isn't popping up. And they're in the same folder as the code. Def small is the code that has the image working, and def stripes is the one that is giving me an error. from tkinter import * import tkinter as tk from tkinter import ttk def small(): s = Tk() s.title('Small Preset Shirt (Not fit to scale)') canvas = Canvas(s, width = 800, height = 100) canvas.pack() b1=ttk.Button(s,text='Click to Start', command = questions) b1.pack() photo = PhotoImage(file =

Trying to add an image that functions like a button, but this error, image “pyimage2” doesn't exist, pops up

烈酒焚心 提交于 2019-12-01 09:27:41
问题 I already have a set of code that is similarly formatted as the one below, and that seems to work. But somehow, the image for this one isn't popping up. And they're in the same folder as the code. Def small is the code that has the image working, and def stripes is the one that is giving me an error. from tkinter import * import tkinter as tk from tkinter import ttk def small(): s = Tk() s.title('Small Preset Shirt (Not fit to scale)') canvas = Canvas(s, width = 800, height = 100) canvas.pack

python calendar widget - return the user-selected date

余生长醉 提交于 2019-12-01 07:10:42
问题 This ttk calendar class makes a calendar based on tkinter. How do make it return the value of the selected date? Below is what I tried, it returned 'NoneType object is not callable': def test(): import sys root = Tkinter.Tk() root.title('Ttk Calendar') ttkcal = Calendar(firstweekday=calendar.SUNDAY) ttkcal.pack(expand=1, fill='both') x = ttkcal.selection() #this and the following line are what i inserted print 'x is: ', x #or perhaps return x if 'win' not in sys.platform: style = ttk.Style()

ttk.Combobox glitch when state is read-only and out of focus

故事扮演 提交于 2019-12-01 04:47:13
When a ttk.Combobox is read-only and not in focus, its text background gets white which differs from the gray field background and makes the combobox look ugly: The desired style would be the second one's. How to make a combobox work like that? SzieberthAdam The solution is to change the ttk style like this: s = ttk.Style() s.map("TCombobox", selectbackground=[ ('!readonly', '!focus', 'SystemWindow'), ('readonly', '!focus', 'SystemButtonFace'), ], ) This changes the behavior of the comboboxes globally. In the following demo (from which the screenshot of the question was made) I defined a

Changing ttk widget text color

懵懂的女人 提交于 2019-12-01 04:20:21
问题 I've searched all over, but have yet to find a simple example showing how to change a minor element of a ttk widget style and applying it dynamically (after widget creation). I have some ttk checkbuttons representing some configuration items, and a ttk button used to update a remote system. The checkbuttons are initialized to the state of the remote system. If the user modifies any of the checkbuttons, I want both the checkbutton text and the update button text to become red, to remind the