tkinter

Avast blocks pip and Pyinstaller

偶尔善良 提交于 2021-01-24 11:57:09
问题 I'm making a Simple GUI Tkinter Program. I was going to compile my Program (with Pyinstaller) but Avast is blocking PIP. So I ignored it. When Compile was Finished. I run the compiled .exe program and the program are saying: failed to execute the script, Avast is blocking. How to fix this error and What am the issue? edit:now Avast is not blocking .exe(but blocking PIP) 回答1: I use avast as well. Avast sandboxes pipenv when installing a new package. Depending on what/if virtualenv your using.

How to have an background image and buttons on it in tkinter?

筅森魡賤 提交于 2021-01-24 11:29:50
问题 I'm writing a simple Python 3 program using tkinter . it should display a background picture and a button. Here is the code: import tkinter from PIL import Image from PIL import ImageTk window = tkinter.Tk() file = Image.open('/Users/dariushmazlumi/Desktop/p.jpg') img = ImageTk.PhotoImage(file) background = tkinter.Label(window, image=img) background.image = img background.pack() window.minsize(height=window.winfo_height(), width=window.winfo_width()) number = 0 def buttonclicked(): global

Drop down list dependent from another drop down tkinter

时间秒杀一切 提交于 2021-01-24 11:13:23
问题 I have one list with car brands in it and a second list with model names from these brands. I want to have two dropdown lists. First you select the brand and in the second dropdown you can select the model. But just models from the selected brand. I got the following code. import tkinter as tk brands = ["Bugatti","VW","Opel","Porsche"] models = [["Veyron","Chiron"], ["Golf","Passat","Polo","Caddy"], ["Insignia","Corsa","Astra"], ["Taycan","Cayenne","911"]] root = tk.Tk() canvas = tk.Canvas

Drop down list dependent from another drop down tkinter

拜拜、爱过 提交于 2021-01-24 11:13:04
问题 I have one list with car brands in it and a second list with model names from these brands. I want to have two dropdown lists. First you select the brand and in the second dropdown you can select the model. But just models from the selected brand. I got the following code. import tkinter as tk brands = ["Bugatti","VW","Opel","Porsche"] models = [["Veyron","Chiron"], ["Golf","Passat","Polo","Caddy"], ["Insignia","Corsa","Astra"], ["Taycan","Cayenne","911"]] root = tk.Tk() canvas = tk.Canvas

Drop down list dependent from another drop down tkinter

我只是一个虾纸丫 提交于 2021-01-24 11:12:12
问题 I have one list with car brands in it and a second list with model names from these brands. I want to have two dropdown lists. First you select the brand and in the second dropdown you can select the model. But just models from the selected brand. I got the following code. import tkinter as tk brands = ["Bugatti","VW","Opel","Porsche"] models = [["Veyron","Chiron"], ["Golf","Passat","Polo","Caddy"], ["Insignia","Corsa","Astra"], ["Taycan","Cayenne","911"]] root = tk.Tk() canvas = tk.Canvas

Drop down list dependent from another drop down tkinter

假如想象 提交于 2021-01-24 11:10:49
问题 I have one list with car brands in it and a second list with model names from these brands. I want to have two dropdown lists. First you select the brand and in the second dropdown you can select the model. But just models from the selected brand. I got the following code. import tkinter as tk brands = ["Bugatti","VW","Opel","Porsche"] models = [["Veyron","Chiron"], ["Golf","Passat","Polo","Caddy"], ["Insignia","Corsa","Astra"], ["Taycan","Cayenne","911"]] root = tk.Tk() canvas = tk.Canvas

How to tell user to only use integers if they input string in Python / Tkinter?

為{幸葍}努か 提交于 2021-01-24 11:08:44
问题 What would be the best way to give an error and tell the user to only input numbers if they type letters as an input? Code that doesn't work: if self.localid_entry.get() == int(self.localid_entry.get(): self.answer_label['text'] = "Use numbers only for I.D." The variable is obtained in Tkinter with: self.localid2_entry = ttk.Entry(self, width=5) self.localid2_entry.grid(column=3, row=2) 回答1: Something like this: try: i = int(self.localid_entry.get()) except ValueError: #Handle the exception

Remove focus from Entry widget

只谈情不闲聊 提交于 2021-01-24 08:49:35
问题 I have simple example, Entry and three separate Frames. from tkinter import * top = Tk() Entry(top, width="20").pack() Frame(top, width=200, height=200, bg='blue').pack() Frame(top, width=200, height=200, bg='green').pack() Frame(top, width=200, height=200, bg='yellow').pack() # Some extra widgets Label(top, width=20, text='Label text').pack() Button(top, width=20, text='Button text').pack() top.mainloop() Once I start writing in Entry, the keyboard cursor stay there, even when I press with

Remove focus from Entry widget

不问归期 提交于 2021-01-24 08:43:26
问题 I have simple example, Entry and three separate Frames. from tkinter import * top = Tk() Entry(top, width="20").pack() Frame(top, width=200, height=200, bg='blue').pack() Frame(top, width=200, height=200, bg='green').pack() Frame(top, width=200, height=200, bg='yellow').pack() # Some extra widgets Label(top, width=20, text='Label text').pack() Button(top, width=20, text='Button text').pack() top.mainloop() Once I start writing in Entry, the keyboard cursor stay there, even when I press with

Python - Store function with parameters

感情迁移 提交于 2021-01-23 08:16:55
问题 I'm using Tkinter for a simple trivia game. There are several buttons, one for each answer, and I'd like to run a checkAnswer function with certain parameters when one is clicked. If I used something like the following: self.option1 = Button(frame, text="1842", command=self.checkAnswer(question=3, answer=2)) Then it would run checkAnswer and use what it returned (nothing). Is there a simple way to store the parameters in the button constructor? 回答1: This is exactly what functools.partial() is