chenaoki / elecpy

Simulation of electrophysiology on Python
Other
3 stars 0 forks source link

cannot show GUI with the default setting and zoom in workplace on Ubuntu 22.04 #9

Open Thesoul20 opened 1 year ago

Thesoul20 commented 1 year ago

basic info

python verison==3.10.10 ipython version==8.11.0 Elecpy==0.1.1 pandas==1.5.3 matplotlib==3.7.0

OS info: Linux username 5.19.0-35-generic #36~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Fri Feb 17 15:17:25 UTC 2 x86_64 x86_64 x86_64 GNU/Linux

cannot open GUI by default

after install QT successfully, I cannot open the GUI after running the command below

from Elecpy.Platform import *
PlatformGUI()

The error log is:

TclError                                  Traceback (most recent call last)
Cell In[1], line 2
      1 from Elecpy.Platform import *
----> 2 PlatformGUI()

File ~/envs/tenv/.venv/lib/python3.10/site-packages/Elecpy/Platform.py:3029, in PlatformGUI.__init__(self)
   3026 self.rt_menu = None
   3028 # start up when the class make a instance
-> 3029 self.start_up()

File ~/envs/tenv/.venv/lib/python3.10/site-packages/Elecpy/Platform.py:3755, in PlatformGUI.start_up(self)
   3750 def start_up(self):
   3751     """
   3752     method: start up the circuit GUI platform
   3753     :return: None
   3754     """
-> 3755     self.build_root_win()
   3756     self.build_oper_bar(self.frame_title)
   3758     self.build_tool_bar(self.frame_tools)

File ~/envs/tenv/.venv/lib/python3.10/site-packages/Elecpy/Platform.py:3043, in PlatformGUI.build_root_win(self, geometry)
   3041 FigureCanvasTkAgg(pyplot.figure(), master=self.root_win)
   3042 if geometry is None:
-> 3043     self.root_win.state('zoomed')
   3044     self.root_win.update()
   3045     self.win_width = self.root_win.winfo_width()

File ~/.pyenv/versions/3.10.10/lib/python3.10/tkinter/__init__.py:2249, in Wm.wm_state(self, newstate)
   2246 def wm_state(self, newstate=None):
   2247     """Query or set the state of this widget as one of normal, icon,
   2248     iconic (see wm_iconwindow), withdrawn, or zoomed (Windows only)."""
-> 2249     return self.tk.call('wm', 'state', self._w, newstate)

TclError: bad argument "zoomed": must be normal, iconic, or withdrawn

accourding to the line of 2248 in the file python3.10/tkinter/__init__.py : iconic (see wm_iconwindow), withdrawn, or zoomed (Windows only), SO must not use zoomed in Unix operation system.

open GUI by other parameter(normal) but cannot zoom in workplace manually

When i change the parameter zoomed to normal in function of Elecpy.Platform.PlatformGUI.build_root_win():

def build_root_win(self, geometry=None):
        """
        method: build a root window for circuit GUI
        :param geometry: e.g., '1920x1200'
        :return: root window
        """
        self.root_win = tk.Tk()
        self.root_win.title('Elecpy->Platform')
        # cancel the affect of matplotlib's plot
        FigureCanvasTkAgg(pyplot.figure(), master=self.root_win)
        if geometry is None:
            # self.root_win.state('zoomed')    # The default setting
##########################################################
            self.root_win.state('normal')          # The new added
###########################################################
            self.root_win.update()
            self.win_width = self.root_win.winfo_width()
            self.win_height = self.root_win.winfo_height()
            geometry = str(self.win_width) + 'x' + str(self.win_height)
        else:
            self.win_width = int(geometry.split('x')[0])
            self.win_height = int(geometry.split('x')[1])
        self.root_win.geometry(geometry)

I can open the GUI successful now, but cannot zoom in the workplace as below pictures show: normally showing with  self.root_win.state('normal') maximum showing  with  self.root_win.state('normal')

open GUI by setting parameter of geometry, also cannot zoom in

when change the parameter of geometry in function Elecpy.Platform.PlatformGUI.build_root_win():

from Elecpy.Platform import *
PlatformGUI().build_root_win(geometry='1920x1200')

I can open GUI successfully, but also cannot zoom out the workplace. changed parameter of geometry

So, how to zoom in workplace manually?

Thesoul20 commented 1 year ago

last but not least, when exit the GUI, the process cannot exit normally:

/home/choose/envs/tenv/.venv/lib/python3.10/site-packages/matplotlib/animation.py:1732: UserWarning: Can not start iterating the frames for the initial draw. This can be caused by passing in a 0 length sequence for *frames*.

If you passed *frames* as a generator it may be exhausted due to a previous display or save.
  warnings.warn(
/home/choose/envs/tenv/.venv/lib/python3.10/site-packages/matplotlib/animation.py:880: UserWarning: Animation was deleted without rendering anything. This is most likely not intended. To prevent deletion, assign the Animation to a variable, e.g. `anim`, that exists until you output the Animation using `plt.show()` or `anim.save()`.
  warnings.warn(
^CException in Tkinter callback
Traceback (most recent call last):
  File "/home/choose/.pyenv/versions/3.10.10/lib/python3.10/tkinter/__init__.py", line 1921, in __call__
    return self.func(*args)
  File "/home/choose/envs/tenv/.venv/lib/python3.10/site-packages/Elecpy/Calculation.py", line 1437, in gui_calculate
    self.open_graph()
  File "/home/choose/envs/tenv/.venv/lib/python3.10/site-packages/Elecpy/Calculation.py", line 1450, in open_graph
    graph.GraphGUI(data_ucomps=self.calc_data['u_comps'],
  File "/home/choose/envs/tenv/.venv/lib/python3.10/site-packages/Elecpy/Graph.py", line 2983, in __init__
    self.mainloop()
  File "/home/choose/envs/tenv/.venv/lib/python3.10/site-packages/Elecpy/Graph.py", line 3026, in mainloop
    self.root_win.mainloop()
  File "/home/choose/.pyenv/versions/3.10.10/lib/python3.10/tkinter/__init__.py", line 1458, in mainloop
    self.tk.mainloop(n)
KeyboardInterrupt
^C
Exception in Tkinter callback
Traceback (most recent call last):
  File "/home/choose/.pyenv/versions/3.10.10/lib/python3.10/tkinter/__init__.py", line 1921, in __call__
    return self.func(*args)
  File "/home/choose/envs/tenv/.venv/lib/python3.10/site-packages/Elecpy/Calculation.py", line 1437, in gui_calculate
    self.open_graph()
  File "/home/choose/envs/tenv/.venv/lib/python3.10/site-packages/Elecpy/Calculation.py", line 1450, in open_graph
    graph.GraphGUI(data_ucomps=self.calc_data['u_comps'],
  File "/home/choose/envs/tenv/.venv/lib/python3.10/site-packages/Elecpy/Graph.py", line 2983, in __init__
    self.mainloop()
  File "/home/choose/envs/tenv/.venv/lib/python3.10/site-packages/Elecpy/Graph.py", line 3026, in mainloop
    self.root_win.mainloop()
  File "/home/choose/.pyenv/versions/3.10.10/lib/python3.10/tkinter/__init__.py", line 1458, in mainloop
    self.tk.mainloop(n)
KeyboardInterrupt