Donny-GUI / tkinter-to-customtkinter-converter

Convert your tkinter scripts and guis to custom tkinter with this command line tool.
GNU General Public License v3.0
41 stars 3 forks source link
customtkinter python3 tkinter

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

Update March 23 2024

Update Feb 13 2024

Update Feb 9 2024

Updates April 14 2023

Coming Up Next

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