0

Today I run into an error using ctk and ttk, and I have no idea how can i fix that.

import customtkinter as ctk
# import ttkbootstrap as ttk

window = ctk.CTk()

button = ctk.CTkButton(window, text = "now it's working")
button.pack()

window.mainloop()

`

The simple code I provided you works as long as the ttk import is commented. If I'm trying to import ttk there is an error:

Traceback (most recent call last):
  File "c:\Users\HP\Desktop\python\tkinter\test.py", line 6, in <module>
    button = ctk.CTkButton(window, text = "now it's working")  
  File "C:\Users\HP\anaconda3\envs\game\lib\site-packages\customtkinter\windows\widgets\ctk_button.py", line 95, in __init__  
    self._canvas = CTkCanvas(master=self,
  File "C:\Users\HP\anaconda3\envs\game\lib\site-packages\customtkinter\windows\widgets\core_rendering\ctk_canvas.py", line 31, in __init__
    super().__init__(*args, **kwargs)
  File "C:\Users\HP\anaconda3\envs\game\lib\site-packages\ttkbootstrap\style.py", line 5169, in __init__wrapper
    func(self, *args, **kwargs)
  File "C:\Users\HP\anaconda3\envs\game\lib\tkinter\__init__.py", line 2688, in __init__
    Widget.__init__(self, master, 'canvas', cnf, kw)
  File "C:\Users\HP\anaconda3\envs\game\lib\tkinter\__init__.py", line 2572, in __init__
    self.tk.call(
_tkinter.TclError: bad screen distance "175.0"

The error occurs even if I don't use any ttk widgets, variables, objects etc. Just importing the module is enough to break the code

I tried reinstalling both packages ctk and ttk and there is no effect. I couldn't find any similar problem online. The issue is not specific to CTkButtons, other widgets also don't work

toyota Supra
  • 3,181
  • 4
  • 15
  • 19
vivats
  • 1
  • Cannot reproduce the error in my Windows 11 with Python 3.11.4, `customtkinter` 5.2.0 and `ttkbootstrap` 1.10.1. – acw1668 Jul 31 '23 at 15:52
  • Cannot reproduce the error either. I'm on Windows 10 Python 3.10.9, customtkinker 5.1.3, ttkbootstrap 1.10.1 – Pragmatic_Lee Jul 31 '23 at 18:13
  • Please clarify your specific problem or provide additional details to highlight exactly what you need. As it's currently written, it's hard to tell exactly what you're asking. – Community Aug 01 '23 at 01:07

0 Answers0