ttk

ttk treeview: alternate row colors

守給你的承諾、 提交于 2019-11-28 07:40:52
How can I set a style for treeview widgets so that alternate rows have different background colors, for example, rows 1,3,5 have white backgrounds and rows 2,4,6 have light blue-grey backgrounds? I'd also like to set gridlines . Matt Fenwick I had this same issue a few months ago. From the tk docs : You can assign a list of tags to each item using the "tags" item configuration option (again, when creating the item or later on). Tag configuration options can then be specified, which will then apply to all items having that tag. Basically, you apply one tag to all of the odd-numbered rows, a

python ttk treeview sort numbers

可紊 提交于 2019-11-28 06:00:59
问题 I'm trying to use the ttk.Treeview sort function illustrated in the answer to this question (Tk treeview column sort) and it works just fine for strings like 'abc', 'bcd', 'cde', etc., but when I try to sort numbers it ends up showing up like this: 1 10 11 2 3 ... I'd like for the data to be sorted such that the output is: 1 2 3 ... 10 11 I know that the values in the treeview columns are strings and that I'm most likely going to need to convert them to integers before sorting, but I can't

How to set the background color of a ttk.Combobox

家住魔仙堡 提交于 2019-11-28 01:24:01
I have a problem to set background color for Combobox using tkinter ttk with 'vista' theme (I'm using Python 3). I've tried code from here ttk.Combobox glitch when state is read-only and out of focus import tkinter as tk from tkinter import ttk root = tk.Tk() combo = ttk.Combobox(root, values=['1', '2', '3']) combo['state'] = 'readonly' combo.pack() tk.Entry(root).pack() style = ttk.Style() style.map('TCombobox', selectbackground=[('readonly', 'red')]) #style.map('TCombobox', fieldbackground=[('readonly', 'blue')]) #not working as well But this will change only background for text, rest part

ttk styling “TNotebook.Tab” background and borderwidth not working

我与影子孤独终老i 提交于 2019-11-28 00:41:19
问题 I been playing around with TKinter trying to create a multiple tab window. When I try to style the TNotebook.Tab it ignores the options background and borderwidth , but it acknowledges foreground . What am I doing wrong? Here is the relevant part of the code: COLOR_1 = 'black' COLOR_2 = 'white' COLOR_3 = 'red' COLOR_4 = '#2E2E2E' COLOR_5 = '#8A4B08' COLOR_6 = '#DF7401' #Notebook Style noteStyler = ttk.Style() noteStyler.configure("TNotebook", background=COLOR_1, borderwidth=0) noteStyler

What is the difference between the widgets of tkinter and tkinter.ttk in Python?

别等时光非礼了梦想. 提交于 2019-11-27 20:13:20
问题 The main tkinter module and its submodule ttk in Python 3 appear to contain identical widgets (i.e. Buttons , CheckButtons , etc.). So, when creating a button, one has the freedom to either use a tkinter.Button widget or a tkinter.ttk.Button . Do you know what is the difference between them? Why would you choose one or the other? 回答1: The widgets in tkinter are highly and easily configurable. You have almost complete control over how they look - border widths, fonts, images, colors, etc. ttk

Tkinter: ProgressBar with indeterminate duration

我的未来我决定 提交于 2019-11-27 17:11:27
问题 I would like to implement a progress bar in Tkinter which fulfills the following requirements: The progress bar is the only element within the main window It can be started by a start command without the need of pressing any button It is able to wait until a task with unknown duration is finished The indicator of the progress bar keeps moving as long as the task is not finished It can be closed by a stop command without the need of pressing any stop bar So far, I have the following code:

ttk.Button returns None

不想你离开。 提交于 2019-11-27 16:18:50
I am trying to use the invoke method of a ttk.Button, as shown at TkDocs (look at "The Command Callback" ), but I keep getting this error: AttributeError: 'NoneType' object has no attribute 'invoke' So, I tried this in the Interactive Shell: ActivePython 3.1.1.2 (ActiveState Software Inc.) based on Python 3.1.1 (r311:74480, Aug 17 2009, 12:30:13) [MSC v.1500 32 bit (Intel)] on win32 >>> from tkinter import * >>> import tkinter.ttk as ttk >>> root = Tk() >>> button = ttk.Button(root, text="Test").grid(row=0, column=0) >>> print(button) None Which shows that ttk.Button returns None. Is ttk

Tkinter insert a Combobox inside a Treeview widget

懵懂的女人 提交于 2019-11-27 15:47:52
For example, lets create a Treeview widget using a class as follows: class FiltersTree: def __init__(self, master, filters): self.master = master self.filters = filters self.treeFrame = Frame(self.master) self.treeFrame.pack() self._create_treeview() self._populate_root() def _create_treeview(self): self.dataCols = ['filter', 'attribute'] self.tree = ttk.Treeview(self.master, columns = self.dataCols, displaycolumns = '#all') Populate root, insert children as usual. At the end of the codeblock, you can see where I want to put a Combobox in the tree, using a Combo object: def _populate_root(self

Matplotlib Crashing tkinter Application

情到浓时终转凉″ 提交于 2019-11-27 07:16:44
I am building an application that embeds a matplotlib figure into the GUI. The problem is that my app is crashing as soon as I add anything from matplotlib into my code (except for the imports, those work as usual). The problem occurs in my class Solver_App at tk.Tk.__init__(self, *args, **kwargs) . When I run the code, I get a massive error and the app crashes. Here is some of my code: import tkinter as tk from tkinter import ttk import matplotlib from matplotlib import pyplot as plt from mpl_toolkits.mplot3d import Axes3D from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg,

How to disable manual resizing of Tkinter's Treeview column?

十年热恋 提交于 2019-11-27 06:19:08
问题 Since I can't horizontally scroll Treeview column due to what appears to be Tk/Tkinter limitation, I want to make it sticky so it is attached to the frame. The issue is that user can manually resize Treeview column which can mess up my interface in a certain way. Is it possible to disable such functionality? Note the size of the column header. User can drag mouse to resize column. I want to disable this. Setting minwidth to a certain value prevents column from shrinking, but it is still