tkinter

How can I get a row in Sqlite3 table with Tkinter Listbox widget?

时光怂恿深爱的人放手 提交于 2021-02-20 03:00:06
问题 I have Python program connected to Sqlite3 database with Tkinter on the frontend. My database table (subjectlist) consists of four columns: [id (unique interger), subject (text), serial (unique interger), is_active (boolean interger)]. Here is my program: import sqlite3 from tkinter import * conn = sqlite3.connect('database.db') c = conn.cursor() c.execute('SELECT COUNT() FROM subjectlist WHERE is_active = 1') number = c.fetchone()[0] c.execute('SELECT * FROM subjectlist WHERE is_active = 1

Tkinter Entry always returning empty string

ぐ巨炮叔叔 提交于 2021-02-19 08:48:05
问题 I'm trying to create a GUI application using Tkinter . This interface is made of the following widgets: a button , an entry and a text. The image below shows it. The idea behind this app is: the user enters a word on the entry and on hit the Meaning button it's meaning is showed in the text widget. My code is splitted in two classes: one for GUI and another for the app itself. GUI (removed the imaged showed before to reduce coding): class Gui: def __init__(self, master=None): if master is

How can I get TK button commands to take in a parameter with a variable (Python)

拟墨画扇 提交于 2021-02-19 08:01:27
问题 This has stumped me for over a week. As the title asks, how can I get TK button commands to take in a parameter with a variable? Here is the exact code I'm using: i=0 # Make a Staff list button staffButton = Button(masterFrame, text='Staff List', width=20, justify=LEFT, #command=lambda:self.openTabHere(isLeft,STAFF_LIST_TAB)) command=lambda:self.openTabHere(isLeft,i)) staffButton.grid(column=0, row=1) # Make a course list button courseButton = Button(masterFrame, text='Course List', width=20,

Tkinter entry character limit [duplicate]

喜你入骨 提交于 2021-02-19 07:50:33
问题 This question already has answers here : Interactively validating Entry widget content in tkinter (8 answers) Closed 4 years ago . I only want to allow one character in a TKinter Entry box. How should I do that? 回答1: Here I am 5 years later :) from tkinter import * Window = Tk() Window.geometry("200x200+50+50") # heightxwidth+x+y mainPanel = Canvas(Window, width = 200, height = 200) # main screen mainPanel.pack() entry_text = StringVar() # the text in your entry entry_widget = Entry(mainPanel

pyinstaller and geckodriver generate issue after compile to exe

a 夏天 提交于 2021-02-19 06:24:05
问题 I hope i will get help here. I'm writing program who will read and export to txt 'devices live logging events' every two minutes. Everything works fine until i generate exe file. What is more interesting, program works on my enviroment(geckodriver and python libraries installed), but does not work on computers without python enviroment. Even if I generate exe with --onedir. Any ideas or tips? part of code is below(without tkinter): browser = webdriver.Firefox() def logs(): global writing

Convert canvas' mouse coords to geographic coords

落爺英雄遲暮 提交于 2021-02-19 06:10:51
问题 I'm trying to create a map with all the cities of Italy using Python-Tkinter and Canvas . I found a picture of a map of Italy with a few highlighted cities online and inserted it to my Canvas . After that I used a function to determine what are the canvas coordinates of the 2 highlighted cities using: import tkinter as tk class Map(): #Creator-Function def __init__(self,parent): self.canvas=tk.Canvas(width=995,height=971,bg='black') self.canvas.pack(expand=0,fill='none') self.gif=tk

Convert canvas' mouse coords to geographic coords

非 Y 不嫁゛ 提交于 2021-02-19 06:10:18
问题 I'm trying to create a map with all the cities of Italy using Python-Tkinter and Canvas . I found a picture of a map of Italy with a few highlighted cities online and inserted it to my Canvas . After that I used a function to determine what are the canvas coordinates of the 2 highlighted cities using: import tkinter as tk class Map(): #Creator-Function def __init__(self,parent): self.canvas=tk.Canvas(width=995,height=971,bg='black') self.canvas.pack(expand=0,fill='none') self.gif=tk

Designating a font in Tkinter?

馋奶兔 提交于 2021-02-19 05:41:25
问题 I want to use a font called Myriad Pro Condensed, which is installed on my computer. If I use Label(infoframe, text="test", font=("Myriad Pro Condensed", 30, "bold")) It just uses the default system font. Using just the family name Myriad Pro works but it doesn't use the condensed version I want to use. How would I go about using the correct font in Tkinter? Here's an MCVE: from tkinter import * root = Tk() label = Label(root, text="test", font=("Myriad Pro Condensed")) label.pack() mainloop(

How to move popup window when scrolling a tkinter treeview?

て烟熏妆下的殇ゞ 提交于 2021-02-19 04:56:14
问题 I have a tkinter treeview with a vertical scrollbar. To make it (look like) editable, I create a popup Entry when the user double-clicks on a cell of the treeview. However, I can't make the popup to move when the treeview is scrolled. import tkinter as tk from tkinter import ttk class EntryPopup(ttk.Entry): def __init__(self, parent, itemId, col, **kw): super().__init__(parent, **kw) self.tv = parent self.iId = itemId self.column = col self['exportselection'] = False self.focus_force() self

How to get a horizontal scrollbar in Tkinter?

柔情痞子 提交于 2021-02-19 04:11:18
问题 I'm learning Tkinter at the moment. From my book, I get the following code for producing a simple vertical scrollbar: from tkinter import * # Import tkinter class ScrollText: def __init__(self): window = Tk() # Create a window window.title("Scroll Text Demo") # Set title frame1 = Frame(window) frame1.pack() scrollbar = Scrollbar(frame1) scrollbar.pack(side = RIGHT, fill = Y) text = Text(frame1, width = 40, height = 10, wrap = WORD, yscrollcommand = scrollbar.set) text.pack() scrollbar.config