Skip to content

Instantly share code, notes, and snippets.

@vigilantPotato
vigilantPotato / entry_return-key.py
Created April 9, 2024 21:59
How to get the text in entry widget by Enter key
import ctypes
import tkinter
def input(event):
l["text"] = e1.get() #set label text
e1.delete(0, tkinter.END) #delete entry
if __name__ == "__main__":
@vigilantPotato
vigilantPotato / entry_2.py
Created April 9, 2024 21:51
How to reflect the text in entry widget to label by using variable
import ctypes
import tkinter
if __name__ == "__main__":
ctypes.windll.shcore.SetProcessDpiAwareness(1)
root = tkinter.Tk()
#variable
var = tkinter.StringVar(root)
@vigilantPotato
vigilantPotato / entry_1.py
Created April 9, 2024 21:35
How to get the text in entry widget
import ctypes
import tkinter
def get_entry_text():
b["text"] = e1.get() #set label text
e1.delete(0, tkinter.END) #delete entry
if __name__ == "__main__":
@vigilantPotato
vigilantPotato / button_widget_w_argument.py
Created April 5, 2024 22:26
How to use button widget (pass argument)
import ctypes
import tkinter
from tkinter import ttk
def clicked(widget):
print(widget["text"] + " is clicked!")
if __name__ == "__main__":
ctypes.windll.shcore.SetProcessDpiAwareness(1)
root = tkinter.Tk()
@vigilantPotato
vigilantPotato / button widget.py
Created April 5, 2024 22:05
How to use button widget
import ctypes
import tkinter
from tkinter import ttk
def clicked():
print("Button widget is clicked!")
if __name__ == "__main__":
ctypes.windll.shcore.SetProcessDpiAwareness(1)
root = tkinter.Tk()
@vigilantPotato
vigilantPotato / matplotlib_in_tkinter_by_subplots.py
Created April 3, 2024 21:55
How to set matplotlib graph into tkinter window (by subplots)
import ctypes
import matplotlib.pyplot as plt
import numpy as np
import tkinter
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2Tk
if __name__ == "__main__":
ctypes.windll.shcore.SetProcessDpiAwareness(1)
@vigilantPotato
vigilantPotato / matplotlib_in_tkinter_with_scale.py
Created April 2, 2024 21:36
How to control matplotlib graph from tkinter
import ctypes
import numpy as np
import tkinter
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2Tk
from matplotlib.figure import Figure
#function slidebar is moved
def update_graph(value):
d = int(value)
@vigilantPotato
vigilantPotato / matplotlib_in_tkinter.py
Created April 2, 2024 21:24
How to set matplotlib graph into tkinter window
import ctypes
import numpy as np
import tkinter
from matplotlib.backends.backend_tkagg import FigureCanvasTkAgg, NavigationToolbar2Tk
from matplotlib.figure import Figure
if __name__ == "__main__":
ctypes.windll.shcore.SetProcessDpiAwareness(1)
@vigilantPotato
vigilantPotato / combobox_2.py
Created March 31, 2024 22:16
How to use combobox-2
import ctypes
import tkinter
from tkinter import ttk
def get_selected():
b["text"] = combobox.get()
if __name__ == "__main__":
@vigilantPotato
vigilantPotato / combobox.py
Created March 31, 2024 21:51
How to use combobox-1
import ctypes
import tkinter
from tkinter import ttk
if __name__ == "__main__":
ctypes.windll.shcore.SetProcessDpiAwareness(1)
root = tkinter.Tk()
var = tkinter.StringVar(root) #variable