Skip to content

Commit

Permalink
[STUDIO] Fix some ttk default values causing problems (#43, #44)
Browse files Browse the repository at this point in the history
  • Loading branch information
ObaraEmmanuel committed Nov 7, 2024
1 parent 2831e53 commit 8d7c58c
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
14 changes: 11 additions & 3 deletions studio/lib/native.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,9 @@ class Checkbutton(PseudoWidget, ttk.Checkbutton):
def __init__(self, master, id_):
super().__init__(master)
self.id = id_
# The default value of the variable is the checkbutton itself
# This causes problems when the checkbutton is serialized
self.configure(variable="")
self.setup_widget()

def set_name(self, name):
Expand All @@ -65,6 +68,7 @@ class Combobox(PseudoWidget, ttk.Combobox):
def __init__(self, master, id_):
super().__init__(master)
self.id = id_
self.configure(cursor="")
self.setup_widget()

def set_name(self, name):
Expand Down Expand Up @@ -241,13 +245,16 @@ class Progressbar(PseudoWidget, ttk.Progressbar):
icon = "progressbar"
impl = ttk.Progressbar
initial_dimensions = 200, 20
_temp_init_var = None

def __init__(self, master, id_):
super().__init__(master)
self.id = id_
self._var = tk.IntVar()
self.config(variable=self._var)
self._var.set(40)
if not self._temp_init_var:
self._temp_init_var = tk.IntVar()
self._temp_init_var.set(40)
self.config(variable=self._temp_init_var)
self.config(variable="")
self.setup_widget()


Expand Down Expand Up @@ -363,6 +370,7 @@ class Treeview(PseudoWidget, ttk.Treeview):
def __init__(self, master, id_):
super().__init__(master)
self.id = id_
self.configure(show="tree headings")
self.setup_widget()


Expand Down
2 changes: 2 additions & 0 deletions studio/ui/editors.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ def spinner_change(self, value):
self._on_change(value)

def set(self, value):
if isinstance(value, (tuple, list)):
value = " ".join(map(str, value))
# Convert to string as values of type _tkinter.Tcl_Obj are common in ttk and may cause unpredictable behaviour
self._spinner.set(str(value))

Expand Down

0 comments on commit 8d7c58c

Please sign in to comment.