Convert your tkinter scripts and guis to custom tkinter with this command line tool. Can determine programming paradigm and import structure to keep consistency across files
please, please, please if you experience a bug or bad operations please submit them to me so i can fix it immediatly. i dont have hundreds of guis to test this on.
tk2ctk - Tkinter to CustomTkinter
Description: tkinter to customtkinter file converter.
Usage: tk2ctk [file] [Options]
tk2ctk -m [file] [file2] [file3] ...
tk2ctk [file] -o [file]
Options:
-h, --help Show this help message and exit
-o, --output Define the output file
-v, --verbose Operate with higher verbosity level
-l, --listboxes Convert listboxes to custom listboxes
-m, --multiple Convert multiple target scripts
-e, --examples Show examples for flags and options
-o Flag is used to set the outfile
-l flag converts tk.Listbox to a custom version
-m is the multiple targets flag. Use this to target more then one tkinter script
-e shows example usages
The SourceConverter class is a standalone class that can convert source to source. That is that it can convert tkinter python source strings to customtkinter source strings.
Case #1 from a string
from .converter import SourceConverter
sc = SourceConverter()
with open("myfile.py", "r) as f:
content = f.read()
ctk_source = sc.from_string(content)
or
import .converter
sc = converter.SourceConverter()
with open("myfile.py", "r) as f:
content = f.read()
ctk_source = sc.from_string(content)
Case #2 from a file
from .converter import SourceConverter
sc = SourceConverter()
ctk_source = sc.from_file(content)
or
import .converter
sc = converter.SourceConverter()
ctk_source = sc.from_file(content)
- Added converter.py file
- Added SourceConverter class
- Now fixes textvariable -> variable function/class instance parameter names.
- Now fixes orient -> orientation function/class instance parameter names.
- tree.py file added to use the ast module to find function and class instances that use the parameters
- New command line interface
- now supports listboxes
- fixed base and meta class tkinter widgets to represent ctk ones
- fixed Checkbutton to CheckBox
- fixed Radiobutton to RadioButton
- No longer falsly import tk.Text
- uses CTkSlider for tk.Scale
- Now supports ttk by default
- General syntax improvements in source code
- General performance improvements
- now converts all widget background_color to bg_color as specified in the property exception in customtkinter
- converts all widget foreground_color to fg_color as specified in the the property exception in customtkinter
- tkinter.ListBox conversion to customtkinter class ScrollableFrame or "ScrollableFrameBox/ScrollableCheckBox/ScrollableSwitchBox/ScrollableLabelBox"
- possible CTkMessageBox addition from Akascape
Thank you Tom Schimansky for this wonderful and beautiful tkinter addition! I am not associated with customtkinter in any way.
Please see https://github.com/TomSchimansky/CustomTkinter
git clone https://github.com/Donny-GUI/tkinter-to-customtkinter-converter.git
cd tkinter-to-customtkinter-converter
python tk_to_ctk.py <target>
git clone https://github.com/Donny-GUI/tkinter-to-customtkinter-converter.git
cd tkinter-to-customtkinter-converter
python3 tk_to_ctk.py <target>
Contains utility functions and constants
get_operating_system()
# get the name of the operating system
pip_str
# Literal string for using pip aka pip or pip3
Contains the WidgetReplacer class