ttk

Python tkinter Combobox

那年仲夏 提交于 2019-12-08 05:29:56
问题 I want to fill my entries when I click in a name of my Combobox without buttons like 'check' to show the values. How can i do that? import tkinter as tk from tkinter import ttk import csv root = tk.Tk() cb = ttk.Combobox(root,state='readonly') labName = ttk.Label(root,text='Names: ') labTel = ttk.Label(root,text='TelNum:') labCity = ttk.Label(root,text='City: ') entTel = ttk.Entry(root,state='readonly') entCity = ttk.Entry(root,state='readonly') with open('file.csv','r',newline='') as file:

How to retrieve the integer value of tkinter ttk Scale widget in Python?

被刻印的时光 ゝ 提交于 2019-12-08 02:39:46
问题 Could anyone advise how to retrieve and update a Label widget with the value from a Scale widget in Python? Currently it shows a very large real number. I have tried to type cast the value but this only works when I print to idle. I tried slider.get() but the label is blank. Also tried int(slider.get()) which works when I print to idle. from tkinter import * from tkinter import ttk root = Tk() root.title("Playing with Scales") mainframe = ttk.Frame(root, padding="24 24 24 24") mainframe.grid

Python 3. TTK. How to change value of the specific cell?

风格不统一 提交于 2019-12-07 21:53:19
问题 I have some problem with tkinter/ttk . So, i know how to get Treeview.focus, but how to change value of the specific cell in this table? Any suggestions? import tkinter as tk import tkinter.ttk as ttk root = tk.Tk() tview = ttk.Treeview(root) tview["columns"] = ("SLOT_1","SLOT_2") tview.column("SLOT_1", width=100 ) tview.column("SLOT_2", width=100) tview.heading("#0",text="Column 0",anchor="w") tview.heading("SLOT_1", text="Column 1") tview.heading("SLOT_2", text="Column 2") def add_item():

Padding specified in style ignored by Ttk Frame

不羁岁月 提交于 2019-12-07 10:03:51
问题 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,

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

懵懂的女人 提交于 2019-12-07 09:39:49
问题 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

Create resizable/multiline Tkinter/ttk Labels with word wrap

百般思念 提交于 2019-12-07 06:57:49
问题 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

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

非 Y 不嫁゛ 提交于 2019-12-07 06:04:26
问题 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. 回答1: Get the id of treeview item you want to

How can I display an image in Python 3 using tkinter/ttk?

 ̄綄美尐妖づ 提交于 2019-12-07 05:46:21
问题 The nub of the matter is, what am I doing wrong in the following code snippet? from tkinter import * from tkinter.ttk import * root = Tk() myButton = Button(root) myImage = PhotoImage(myButton, file='myPicture.gif') myButton.image = myImage myButton.configure(image=myImage) root.mainloop() The error message I get from idle3 is as follows: >>> Traceback (most recent call last): File "/home/bob/Documents/Python/tkImageTest.py", line 9, in <module> myButton.configure(image=myImage) File "/usr

Create new ttk widget from tkinter

一个人想着一个人 提交于 2019-12-07 05:15:26
问题 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

Why does my ttk.Treeview click handler return the wrong item on tree.focus()?

别说谁变了你拦得住时间么 提交于 2019-12-07 03:16:52
问题 I have a simple script using a ttk.Treeview instance that I'm populating with the contents of a file system tree. I want to perform a certain operation when (leaf) items are clicked so I configured a handler like so: self.tree.tag_bind('#entry', '<1>', self.onClick) In the method onClick I am simply printing out the item that was clicked, like so: def onClick(self, event): item_id = str(self.tree.focus()) print 'Selected item was %s' % item_id item = self.tree.item(item_id) flag = '#another