ttk

Change width of dropdown listbox of a ttk combobox

被刻印的时光 ゝ 提交于 2021-02-05 04:44:17
问题 I am trying to change to width of the popdown list of the ttk Combobox. Setting the width of the Combobox also changes the width of the Listbox, making part of the values unreadable. I read this solution in Tk/Tcl but I am not familiar with this language and would like to solve the problem with Python. I tried changing the theme parameters but it does not seem to help. Below is a piece of sample code. import tkinter as tk from tkinter import ttk root = tk.Tk() root.title("testing the combobox

How to align text to the right in ttk Treeview widget?

元气小坏坏 提交于 2021-02-04 18:13:45
问题 I am using a ttk.Treeview widget to display a list of Arabic books . Arabic is a right-to-left language, so the text should be aligned to the right. The justify option that is available for Label and other ttk widgets does not seem to work for Treeview . Does anyone know how to do this? 回答1: The ttk.Treeview widget has an anchor option you can set for each column. To set the anchor of a column to the right side use: ttk.Treeview.column(column_id, anchor=Tkinter.E) 回答2: In addition to the

Tkinter Treeview heading styling

爱⌒轻易说出口 提交于 2021-02-03 13:36:33
问题 I want to change the background colour of the treeview headings. I have identified the element option of the Treeview.Heading layout responsible for this: Treeheading.cell. The problem is that this setting does not work on the 'vista' theme (Due to drawing issues I assume). working code (theme looks terrible though): from tkinter import * from tkinter import ttk p=Tk() separator = PanedWindow(p,bd=0,bg="#202322",sashwidth=2) separator.pack(fill=BOTH, expand=1) _frame = Frame(p,bg="#383838") t

Tkinter ttk: background/foregound color will not work on my computer

我只是一个虾纸丫 提交于 2021-01-29 13:10:46
问题 If I run this code via IDLE or a virtual environment in pycharm on both windows 10 and 7: import tkinter as tk from tkinter import ttk x = tk.Tk() y = ttk.Treeview(x) y.insert('',0,values=['red', 'blue'], tags= ('even',)) y['columns'] = ('color1','color2') for item in y['columns']: y.heading(item, text=item) y.tag_configure('even',foreground='yellow',font=('',25)) y.pack() x.mainloop() It changes the font but not the background color. This code does work when run from https://repl.it

Creating a Treeview with Checkboxes

淺唱寂寞╮ 提交于 2021-01-29 08:04:25
问题 I am trying to build an application based on the following usage example (How to create a tree view with checkboxes in Python). This example builds a Treeview with checkboxes using the Tix library. However, when I run this example, whenever a Checkbox is checked, the text label of that box disappears. Could someone help me to avoid the behaviour mentioned just above? import Tix class View(object): def __init__(self, root): self.root = root self.makeCheckList() def makeCheckList(self): self.cl

Update on the fly a ttk.OptionMenu without affecting its previous callback/command

若如初见. 提交于 2021-01-29 07:26:28
问题 I am doing a large GUI with different ttk.OptionMenu widgets that need to be updated often depending on the interaction with the user. Each time the user selects another value from the menu, there is a function callback by the widget via the command input. The command works fine until I need to update the possible values within the OptionMenu widget. After updating using add_command , my previous callback does not work anymore. Is there any way of updating the possible inputs of a ttk

How to get a Treeview columns to fit the Frame it is within

北城余情 提交于 2021-01-29 02:03:52
问题 When dynamically changing a treeviews data, I want the rows to expand to the size of the treeview's frame. Currently if I make the GUI fullscreen and re-fill the data it only uses a small portion of the available screen-size, i.e. the columns don't resize or stretch to fill the width of the screen (i'm not too concerned with the rows filling). I have produced a minimal working example below: import tkinter as tk from tkinter import ttk import random class App(): def __init__(self): self.root

How to detect resizing of ttk.Treeview column?

痴心易碎 提交于 2021-01-28 09:39:33
问题 I have a ttk.Notebook and each tab contains a ttk.Treeview . All treeviews have the same columns but contain different items, like in the code below. import tkinter as tk from tkinter import ttk root = tk.Tk() notebook = ttk.Notebook(root) notebook.pack() tree1 = ttk.Treeview(notebook, columns=['a', 'b', 'c']) tree1.insert('', 'end', text='item1', values=('a1', 'b1', 'c1')) tree2 = ttk.Treeview(notebook, columns=['a', 'b', 'c']) tree2.insert('', 'end', text='item2', values=('a2', 'b2', 'c2'))

ttk Menu wont unpost

痞子三分冷 提交于 2021-01-28 08:37:48
问题 I wanted to make a simple pop-up message that shows the name of the options represented as icons when the mouse enters them and hide when it leavs. This icons are images within buttons, and I have been able to show the message when entering the button using a Menu widget, but when the mouse leaves the button it dose NOT unpost, unless there's a klick. I tryed deleting the cascade, but the same happens, the difference is that he menu at that moment has no text. I tryed to .destroy() the menu

Tkinter's grid() geometry manager ignoring ipadx argument

不羁的心 提交于 2021-01-27 20:27:40
问题 While extending the code based on this awesome Bryan Oakley's answer (btw his code works great, it's just me the one that can't make the padding work) I've found that the argument ipadx passed to .grid() is being ignored on the line: e.grid(row=row, column=column, sticky=tk.N+tk.E+tk.S+tk.W, ipadx=5, ipady=3) from the following script: import tkinter as tk from tkinter import ttk class SimpleTableInput(tk.Frame): def __init__(self, parent, rows, columns): tk.Frame.__init__(self, parent) self.