tkinter

Tkinter window in canvas doesn't fill its parent in height

我的梦境 提交于 2021-01-27 20:28:18
问题 I would like to have my scrollbar in the bottom of the frame and my text widgets filling the whole frame above the scrollbar. I found some solution about the width configuration here but when I try to replace width with height, it does not work correctly. from tkinter import * from tkinter import ttk class MainView(Frame): def FrameHeight(self, event): canvas_height = event.height self.canvas.itemconfig(self.canvas_frame, height=canvas_height) def OnFrameConfigure(self, event): self.canvas

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.

Is it possible to change the menu border color in tkinter

我的未来我决定 提交于 2021-01-27 20:15:00
问题 I want to change the border color of the drop down menu items. white theme: Using Python 3.7 and tkinter - my GUI app offer both dark and light themes, so I change the background and foreground colors dynamically. I was able to do it for most widgets, but I did not find a way to change the border color for the drop down menu items. Here's a sample snippet of how the file_menu is defined: self.menubar = tk.Menu(self) self.file_menu = tk.Menu(self.menubar, tearoff=0) self.file_menu.add_command

AttributeError: 'Button' object has no attribute 'set' - tkinter

流过昼夜 提交于 2021-01-27 19:04:34
问题 I'm getting an error: self.button.set(str(self)) AttributeError: 'Button' object has no attribute 'set' I can't figure out what to change to make it work. Here is the important parts of the code: class Cell: def show_word(self): """ Shows the word behind the cell """ if self.hidden == True: self.hidden = False else: self.hidden = True self.button.set(str(self)) class Memory(Frame): def create_widgets(self): """ Create widgets to display the Memory game """ # instruction text Label(self, text

How to increase Checkbutton size - Tkinter

你离开我真会死。 提交于 2021-01-27 18:46:37
问题 Is it possible to enlarge the tiny check box of the Checkbutton object? The size is out of proportion when increasing the text size. I searched through the following link (Checkbutton) and can't find anything about the actual size of the box. Thank you for your help. 回答1: It is not possible to change the size of the checkbutton, but you can supply your own images. So, one solution is to create your own images at various sizes. 来源: https://stackoverflow.com/questions/46265567/how-to-increase

How can I change the colour of a button when clicked at runtime? [duplicate]

眉间皱痕 提交于 2021-01-27 18:43:29
问题 This question already has answers here : List of All Tkinter Events (2 answers) Closed 4 months ago . button1=Button(root,text="A1",width=8).grid(row=0,column=0) button2=Button(root,text="A2",width=8).grid(row=0,column=1) label1=Label(root,text=" ",padx=20).grid(row=0,column=2) button22=Button(root,text="A3",width=8).grid(row=0,column=3,sticky='E') button23=Button(root,text="A4",width=8).grid(row=0,column=4,sticky='E') I'm trying to make seat arrangement system for a school project. I have an

how to resize an image to fit the label size? (python)

孤者浪人 提交于 2021-01-27 18:20:53
问题 My aim is to create a random country generator, and the flag of the country that is picked will appear. However, if the image file is bigger than the predetermined size of the label, then only part of the image is displayed. Is there a way of resizing the image to fit the label? (All other questions like this which I have seen have been answered, mentioning the PIL or Image modules. I tested them both, and they both came up with this error: Traceback (most recent call last): File "C:\python

Python Tkinter button not appearing?

℡╲_俬逩灬. 提交于 2021-01-27 17:11:48
问题 I'm new to tkinter and I have this code in python: #import the tkinter module from tkinter import * import tkinter calc_window = tkinter.Tk() calc_window.title('Calculator Program') button_1 = tkinter.Button(text = '1', width = '30', height = '20') button_1 = '1' calc_window.mainloop() But when I run it, the button doesn't appear. Does anyone know why? Thank you! 回答1: Getting a widget to appear requires two steps: you must create the widget, and you must add it to a layout. That means you

Python Error - TypeError: item 1 in _argtypes_ passes a union by value, which is unsupported

百般思念 提交于 2021-01-27 15:07:58
问题 I think this is a not a programming specific bug, but is caused by some libraries. I am transferring my project to a new PC, which I have freshly setup with anaconda etc. using python 3.7.6. Executing the task on the old machine works fine, here I have also used anaconda with python 3.7 (not sure if it was 3.7.6 but I could check this, i just used while creating the environment python=3.7). When I now try to run my program, I receive: Exception in Tkinter callback Traceback (most recent call

tkinter variable trace method

♀尐吖头ヾ 提交于 2021-01-27 14:26:02
问题 I am trying to activate callback function as the user type in to the tkinter entry box. According to effbot.org, You can use the trace method to attach “observer” callbacks to the variable. The callback is called whenever the contents change: So i tired this, import Tkinter as tk window2=tk.Tk() anf_frame1=tk.Frame(window2,bg='white',relief='groove',bd=0,width=1190,height=175) anf_frame1.place(x=10,y=50) def myfunction(*args): print 'pass' stringvar1 = tk.StringVar(anf_frame1) stringvar1