Skip to content

Convert your tkinter scripts and guis to custom tkinter with this command line tool.

License

Notifications You must be signed in to change notification settings

Donny-GUI/tkinter-to-customtkinter-converter

Repository files navigation

Tkinter to CustomTkinter Converter

Python_logo_icon

tkinter-to-customtkinter-converter

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.

New Cmdline Application

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

Screenshot 2024-02-13 195702

Before

before

After

after

New Source Converter Class

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.

Usage

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)

Update April 18 2024

  • Added converter.py file
  • Added SourceConverter class

Update March 23 2024

  • 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

Update Feb 13 2024

  • New command line interface
  • now supports listboxes

Update Feb 9 2024

  • 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

Updates April 14 2023

  • 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

Coming Up Next

  • tkinter.ListBox conversion to customtkinter class ScrollableFrame or "ScrollableFrameBox/ScrollableCheckBox/ScrollableSwitchBox/ScrollableLabelBox"
  • possible CTkMessageBox addition from Akascape

Thank you!

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

Getting Started

Windows Users

git clone https://github.com/Donny-GUI/tkinter-to-customtkinter-converter.git
cd tkinter-to-customtkinter-converter
python tk_to_ctk.py <target> 

Unix/Linux Users

git clone https://github.com/Donny-GUI/tkinter-to-customtkinter-converter.git
cd tkinter-to-customtkinter-converter
python3 tk_to_ctk.py <target> 

Files

tkinter-to-customtkinter.util

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

tkinter-to-customtkinter.widget_replacer

Contains the WidgetReplacer class

About

Convert your tkinter scripts and guis to custom tkinter with this command line tool.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages