Skip to content

Commit 355a8a4

Browse files
committed
Make GUI work again in Tk.
1 parent f51be40 commit 355a8a4

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

pymol_plugin_dynamics.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@
131131

132132

133133
# This function will initialize all plugin stufs
134-
def init_function(travis_ci=False, parent=None):
134+
def init_function(travis_ci=False):
135135
status = ["ok", ""]
136136
# Make sure HOME environment variable is defined before setting up directories...
137137
home_dir = os.path.expanduser('~')
@@ -172,7 +172,7 @@ def init_function(travis_ci=False, parent=None):
172172
if not travis_ci:
173173
# Creating objects - data from those windows will be used by rootWindow
174174
gui_library = "tk"
175-
create_gui(gui_library, status, simulation_parameters, parent)
175+
create_gui(gui_library, status, simulation_parameters)
176176
return status, simulation_parameters
177177

178178

@@ -1569,13 +1569,13 @@ def error_message(s_params):
15691569

15701570
# init function - puts plugin into menu and starts 'init_function' after clicking.
15711571
def __init_plugin__(self=None):
1572-
plugins.addmenuitem("Dynamics_Gromacs {}".format(plugin_ver), init_function)
1572+
plugins.addmenuitem("Dynamics Gromacs {}".format(plugin_ver), init_function)
15731573

15741574

1575-
def create_gui(gui_library, status, s_parameters, parent):
1575+
def create_gui(gui_library, status, s_parameters):
15761576
if status[0] == "ok":
15771577
if gui_library == "tk":
1578-
root_window(status, s_parameters, parent)
1578+
root_window(status, s_parameters)
15791579
else:
15801580
if gui_library == "tk":
15811581
tkMessageBox.showerror("Initialization error", status[1])
@@ -1601,9 +1601,13 @@ def create_gui(gui_library, status, s_parameters, parent):
16011601

16021602
# Don't care too much of below code quality, as Tk it depreciated and will be removed in plugin version 3.1
16031603
# Root menu window
1604-
def root_window(status, s_params, parent=None):
1605-
# root = Toplevel(parent)
1606-
root = plugins.get_tk_root()
1604+
def root_window(status, s_params):
1605+
# First try to get this root fails, but the second try works fine.
1606+
try:
1607+
root_pymol = plugins.get_tk_root()
1608+
except ModuleNotFoundError:
1609+
root_pymol = plugins.get_tk_root()
1610+
root = Toplevel(root_pymol)
16071611
root.wm_title("Dynamics with Gromacs" + plugin_ver)
16081612
calculationW = CalculationWindow()
16091613
waterW = WaterWindows()

0 commit comments

Comments
 (0)