tkinter

Random fill colour for shapes in Python(TKinter)

我的未来我决定 提交于 2021-02-08 05:37:02
问题 I am wondering how to get a random color out of a list to use in the draw_rectangle() colors = ["red", "orange", "yellow", "green", "blue", "violet"] canvas.create_rectangle(self.x, self.y, self.x + 60, self.y + 60, fill = random.choice(colors)) This causes my code to crash, what else can I try? 回答1: You can use random.choice like this import random colors = ["red", "orange", "yellow", "green", "blue", "indigo", "violet"] canvas.create_rectangle(self.x, self.y, self.x + 60, self.y + 60, fill

Tkinter Label not appearing

╄→гoц情女王★ 提交于 2021-02-08 05:17:20
问题 I am making a game for a raspberry pi with a 10inch touch screen, I have decided to use Tkinter to be able to interact with the pi. Currently once the user has selected their game mode, and they are taken to this screen, I then try and place a label on this screen showing their current level, the code runs, tkinter window stops responding however code in the commandline continues. Here is the code that is ran on the Survival Screen: def start_survival(game): while game.health != 0: print(str

Tkinter Label not appearing

痴心易碎 提交于 2021-02-08 05:16:01
问题 I am making a game for a raspberry pi with a 10inch touch screen, I have decided to use Tkinter to be able to interact with the pi. Currently once the user has selected their game mode, and they are taken to this screen, I then try and place a label on this screen showing their current level, the code runs, tkinter window stops responding however code in the commandline continues. Here is the code that is ran on the Survival Screen: def start_survival(game): while game.health != 0: print(str

Adjust widget size according to window size using grid geometry and screen size

人走茶凉 提交于 2021-02-07 21:48:41
问题 I want to use grid geometry to change the size of widget according to size of window(maximize or minimize). Example: If a window is made and its look fulfilled in minimize mode but on expanding it shows some blank space .I want to expand the widget in such a way to fulfill that blank space. If the LCD is changed the window should look same.It should also manage its size according to different LCD size I used grid_rowconfigure and grid_columnconfigure methods, but in my program I am deleting

Adjust widget size according to window size using grid geometry and screen size

蓝咒 提交于 2021-02-07 21:48:10
问题 I want to use grid geometry to change the size of widget according to size of window(maximize or minimize). Example: If a window is made and its look fulfilled in minimize mode but on expanding it shows some blank space .I want to expand the widget in such a way to fulfill that blank space. If the LCD is changed the window should look same.It should also manage its size according to different LCD size I used grid_rowconfigure and grid_columnconfigure methods, but in my program I am deleting

Python tkinter Entry widget status switch via Radio buttons

南楼画角 提交于 2021-02-07 14:44:27
问题 a simple question (not so simple for a tkinter newby like me): I'm building a GUI and I want to have two radio buttons driving the status (enabled or disabled) of an Entry widget, into which the user will input data. When the first radio button is pressed, I want the Entry to be disabled; when the second radio button is pressed, I want the Entry to be disabled. Here is my code: from Tkinter import * root = Tk() frame = Frame(root) #callbacks def enableEntry(): entry.configure(state=ENABLED)

Python tkinter Entry widget status switch via Radio buttons

喜你入骨 提交于 2021-02-07 14:43:59
问题 a simple question (not so simple for a tkinter newby like me): I'm building a GUI and I want to have two radio buttons driving the status (enabled or disabled) of an Entry widget, into which the user will input data. When the first radio button is pressed, I want the Entry to be disabled; when the second radio button is pressed, I want the Entry to be disabled. Here is my code: from Tkinter import * root = Tk() frame = Frame(root) #callbacks def enableEntry(): entry.configure(state=ENABLED)

Python tkinter Entry widget status switch via Radio buttons

无人久伴 提交于 2021-02-07 14:43:26
问题 a simple question (not so simple for a tkinter newby like me): I'm building a GUI and I want to have two radio buttons driving the status (enabled or disabled) of an Entry widget, into which the user will input data. When the first radio button is pressed, I want the Entry to be disabled; when the second radio button is pressed, I want the Entry to be disabled. Here is my code: from Tkinter import * root = Tk() frame = Frame(root) #callbacks def enableEntry(): entry.configure(state=ENABLED)

How to show markdown format text in tkinter?

大憨熊 提交于 2021-02-07 12:59:13
问题 In python-3.x with tkinter GUI, I developed a program with a regular simple window. I want to show a markdown format string saved in a string called markdownText on program window: markdownText='_italic_ or **bold**' desired output is: italic or bold Is there any solution? 回答1: I was just searching for a similar solution, and it does indeed not seem like there is a default module/class/library for the combination of Python, TkInter and markdown. However a continued search revealed the

Configure tkinter/ttk widgets with transparent backgrounds, ttk frame background colors?

∥☆過路亽.° 提交于 2021-02-07 12:25:46
问题 Is it possible to configure tkinter or ttk widgets ( Label , Entry , Text ) with a transparent background so that they can be placed in containers with custom background colors or on top of canvas graphics or images? I'm also looking for a way to change the background color of a ttk Frame widget? Do I need to use the new ttk Style objects to accomplish the above? (I'm new to tkinter/ttk and still trying to get my head around the proper way to do things). 回答1: Except on OSX, what you want can