Includes 3 files: 1. demo.py file 2. ComBoPicker.py file 3. ComBoPicker1.py file Question Method How to dynamically assign values COMBOPICKER.values = [1,2,3,4] Get the selected value 1.COMBOPICKER.current_value 2.COMBOPICKER.get() 3.COMBOPICKER.entry_var.get() The effect is as follows: demo.py file from tkinter import * from ComBoPicker import Combopicker# Import custom drop-down multiple selection box from ComBoPicker1 import Combopicker as […]
Tag: tkinter
Display icon in toolbar when python tkinter program is minimized
The effect is as follows: import win32api, win32con, win32gui_struct, win32gui import os, tkinter as tk class SysTrayIcon (object): ”’SysTrayIcon class is used to display taskbar icons”’ QUIT = ‘QUIT’ SPECIAL_ACTIONS = [QUIT] FIRST_ID = 5320 def __init__(s, icon, hover_text, menu_options, on_quit, tk_window = None, default_menu_index=None, window_class_name = None): ”’ icon The path to the icon […]
Date control in python tkinter
1. Date control (with time) The effect is as follows: # Date control with time import tkinter as tk from tkinter import ttk import tkinter.font as tkFont import calendar import datetime import calendar datetime = calendar.datetime.datetime timedelta = calendar.datetime.timedelta classCalendar: def __init__(s, point = None): s.master = tk.Toplevel() s.master.withdraw() s.master.attributes(‘-topmost’ ,True) fwday = calendar.SUNDAY year […]
[Tkinter Series 13/15] Standardized appearance and options database
27. Standardized appearance and options database Colors, fonts, and other options can be easily applied to widgets as you create them. However If you want many widgets to have the same background color or font, it would be tedious to specify each option every time, as well It’s good to let users override your choices […]
Build a Tic-Tac-Toe game in Python using Tkinter!
1. Description Do you remember playing tic-tac-toe as a kid? This is a simple game that can be played on a piece of paper with just a pen or pencil. But did you know you can also create a tic-tac-toe game using Python’s Tkinter library? In this article, we’ll walk through the process of creating […]
[Tkinter Series 09/15] Widget (Scrollbar
22. Widget Scrollbar Many widgets, such as list boxes and canvases, can act like sliding a window into a larger virtual area. You can connect scroll bar widgets to them to provide users with a way to slide the view relative to the content. Here is a screenshot of the entry widget with the associated […]
[Tkinter Series 08/15] Widgets (Radiobutton, Scale)
20. Widget Radiobutton Radio buttons are a set of related widgets that allow the user to select only one of a set of options. Each radio button consists of two parts: indicator and label: The indicator is the diamond-shaped portion that turns red in the selected item. Labels are text, but you can use images […]
Tkinter Series 10/15Widget (Spin)
23. Widget Spinbox This widget allows the user to select values from a given collection. These values can range from numbers to a fixed set of strings. Spinbox On the screen, a has an area that displays the current value and a pair of arrows. Spinbox The user can click the up arrow to advance […]
[Tkinter Series 04/15] Interface widgets (select button, line editor)
9. Widget Checkbutton A checkbox widget (sometimes called a “checkbox”) is a two-way option that allows users to read and select. The above image shows how the check buttons are viewed in the off (0) and on (1) state Implementation: This is a screenshot of two check buttons using 24 point Era font. The indicator […]