tkinter

Making a tkinter scrollbar wider

徘徊边缘 提交于 2021-02-05 09:47:01
问题 I'm coding in Python 2.7/tkinter in Windows and am putting a scrollbar on a listbar, which I can do easily enough (thanks effbot.org). However, I also want to make the scrollbar wider - it will be used on a touchscreen so the easier it is to select it, the better. I figured the width attribute would make it wider, but all it does is create some blank space. What am I doing wrong here? Code: from Tkinter import * top = Tk() scrollbar = Scrollbar(top, width=100) scrollbar.pack(side=RIGHT, fill

Running a thread with Tkinter object

流过昼夜 提交于 2021-02-05 09:46:39
问题 When I push the button the scan_open_ports start working until the line ip_list.curselection() where it stops, this line blocks the running of the function... I wanted to know why and how to fix that? Thanks def scan_open_ports(): #long runtime function print "Asdasd\" ip_list.curselection() def thr_open_ports(): threading.Thread(target=scan_open_ports).start() ip_list = Listbox() scan_ports = Button(window, text="Scan Open Ports", command= thr_open_ports, height = 10, width = 20) 回答1: I have

Making a tkinter scrollbar wider

时光怂恿深爱的人放手 提交于 2021-02-05 09:46:36
问题 I'm coding in Python 2.7/tkinter in Windows and am putting a scrollbar on a listbar, which I can do easily enough (thanks effbot.org). However, I also want to make the scrollbar wider - it will be used on a touchscreen so the easier it is to select it, the better. I figured the width attribute would make it wider, but all it does is create some blank space. What am I doing wrong here? Code: from Tkinter import * top = Tk() scrollbar = Scrollbar(top, width=100) scrollbar.pack(side=RIGHT, fill

Can not import vlc to python program

…衆ロ難τιáo~ 提交于 2021-02-05 09:44:48
问题 I'm trying to reproduce a video with sound in python Tkinter through VLC, but cannot run the file since I get an error when running the line import vlc. I have python 3 at 32 bits, VLC player at 32 bits and installed it through pip install python-VLC , which was successful and then try to run the code and get this error: File "C:/Users/momoh/Documents/GitHub/CNDH/CNDH.py", line 5, in <module> import vlc File "C:\Users\momoh\AppData\Local\Programs\Python\Python36-32\lib\site-packages\vlc.py",

Why are frames resizing when using python tkinter?

守給你的承諾、 提交于 2021-02-05 09:38:12
问题 My code is the following: import tkinter as tk #setting up window. root = tk.Tk() root.title("CSV Maker") root.geometry("600x300") #setting up frames. leftFrame = tk.Frame(root, bg="red", width=300, height=300) rightFrame = tk.Frame(root, bg="blue", width=300, height=300) #placing frames on window. leftFrame.grid(row=0, column=0) rightFrame.grid(row=0, column=1) #setting up labels. inputPathLabel = tk.Label(leftFrame, text="Input File Path:") #placing labels on frames. inputPathLabel.grid(row

Why are frames resizing when using python tkinter?

我们两清 提交于 2021-02-05 09:38:10
问题 My code is the following: import tkinter as tk #setting up window. root = tk.Tk() root.title("CSV Maker") root.geometry("600x300") #setting up frames. leftFrame = tk.Frame(root, bg="red", width=300, height=300) rightFrame = tk.Frame(root, bg="blue", width=300, height=300) #placing frames on window. leftFrame.grid(row=0, column=0) rightFrame.grid(row=0, column=1) #setting up labels. inputPathLabel = tk.Label(leftFrame, text="Input File Path:") #placing labels on frames. inputPathLabel.grid(row

Python: Changing ttk button color depending on current color?

耗尽温柔 提交于 2021-02-05 09:32:28
问题 I'm trying to do some things with styling in ttk for the first time. My goal just now is to highlight the background color of some styled buttons when the mouse goes over them, but the button has some states and will have different colors at different moments, so I tried this: code for the button from PIL.ImageTk import PhotoImage import tkinter.ttk as ttk from random import random class ImgButton(ttk.Button): def __init__(self, master=None, **kw): super().__init__(master, **kw) self.img = kw

Python - How to change the color of one button in a list of buttons

╄→尐↘猪︶ㄣ 提交于 2021-02-05 09:29:32
问题 I'm trying to change the color of a button. Here is the code. for i in range(6): for j in range (6): if i == 0 and j == 0: grids6 = tk.Button(mFrame, bg='blue', highlightcolor="black", highlightthickness=1, state = "disabled", width = 11, height = 5) grids6.grid(row = i, column = j) elif i == 5 and j == 5: grids6 = tk.Button(mFrame, bg='red', highlightcolor="black", highlightthickness=1, state = "disabled", width = 11, height = 5) grids6.grid(row = i, column = j) else: grids6 = tk.Button

Tkinter Create OptionMenus With Loop

倾然丶 夕夏残阳落幕 提交于 2021-02-05 09:29:16
问题 I have created a code to create tkinter OptionMenus with values in a dictionary using a for loop. The code seems to work successfully, with OptionMenus appearing with keywords on a window as desired... import tkinter as tk from tkinter import * class Example: def __init__(self): #Dictionary with categories and their relative keywords self.categorykeywords={"Category 1":["Keyword 1", "Keyword 2", "Keyword 3"], "Category 2":["Keyword A","Keyword B","Keyword C"], "Category 3":["Another Keyword"]

Python - How to change the color of one button in a list of buttons

人走茶凉 提交于 2021-02-05 09:28:49
问题 I'm trying to change the color of a button. Here is the code. for i in range(6): for j in range (6): if i == 0 and j == 0: grids6 = tk.Button(mFrame, bg='blue', highlightcolor="black", highlightthickness=1, state = "disabled", width = 11, height = 5) grids6.grid(row = i, column = j) elif i == 5 and j == 5: grids6 = tk.Button(mFrame, bg='red', highlightcolor="black", highlightthickness=1, state = "disabled", width = 11, height = 5) grids6.grid(row = i, column = j) else: grids6 = tk.Button