Skip to content

Commit d47ce14

Browse files
Merge pull request #985 from TheDeanLab/mac-right-click
Update features_popup.py
2 parents 13a317b + d088a96 commit d47ce14

File tree

1 file changed

+15
-22
lines changed

1 file changed

+15
-22
lines changed

src/navigate/controller/sub_controllers/features_popup.py

Lines changed: 15 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import inspect
3636
import json
3737
import os
38+
import platform
3839

3940
# Third party imports
4041
from PIL import Image, ImageTk
@@ -335,8 +336,13 @@ def draw_feature_list_graph(self, new_list_flag=True):
335336

336337
btn.grid(row=0, column=i * 2, sticky="", pady=(30, 0))
337338
btn["width"] = 20
338-
# right click
339-
btn.bind("<Button-3>", self.show_menu(i, flag))
339+
340+
# Right-Click Bindings
341+
if platform.system() == "Darwin":
342+
btn.bind("<ButtonPress-2>", self.show_menu(i, flag))
343+
else:
344+
btn.bind("<Button-3>", self.show_menu(i, flag))
345+
340346
if i == 0:
341347
self.feature_list_view.update()
342348
feature_icon_width = btn.winfo_width()
@@ -355,7 +361,6 @@ def draw_feature_list_graph(self, new_list_flag=True):
355361
# draw loop arrows
356362
image_width = feature_icon_width * (l + 1) + al_width * l
357363
image_height = self.calculate_arrow_image_height()
358-
arrow_height = 50
359364
stack = []
360365
arrow_image = None
361366
space = 30
@@ -418,6 +423,7 @@ def draw_feature_list_graph(self, new_list_flag=True):
418423
end_pos = c * (feature_icon_width + al_width) + feature_icon_width // 2
419424
if arrow_image:
420425
image_gif = arrow_image.convert("P", palette=Image.ADAPTIVE)
426+
421427
#: ImageTk.PhotoImage: The image of the feature list graph.
422428
self.image = ImageTk.PhotoImage(image_gif)
423429
al = tk.Label(self.feature_list_view, image=self.image)
@@ -433,7 +439,7 @@ def show_config_popup(self, idx):
433439
434440
Returns
435441
-------
436-
func
442+
func : function
437443
The function to show the feature configuration popup
438444
"""
439445
feature = self.features[idx]
@@ -534,11 +540,6 @@ def update_feature_parameters(popup):
534540
----------
535541
popup : navigate.view.popups.feature_list_popup.FeatureConfigPopup
536542
The feature configuration popup
537-
538-
Returns
539-
-------
540-
func
541-
The function to update the feature parameters
542543
"""
543544
widgets = popup.get_widgets()
544545
feature_name = popup.feature_name_widget.get()
@@ -581,10 +582,12 @@ def show_menu(self, idx, flag=True):
581582
----------
582583
idx : int
583584
The index of the feature
585+
flag : bool, optional
586+
Whether the feature is a decision node, by default True
584587
585588
Returns
586589
-------
587-
func
590+
func : function
588591
The function to show the popup menu
589592
"""
590593

@@ -688,11 +691,6 @@ def insert_after(idx):
688691
----------
689692
idx : int
690693
The index of the feature
691-
692-
Returns
693-
-------
694-
func
695-
The function to insert the feature after the current feature
696694
"""
697695
self.features.insert(
698696
idx,
@@ -715,14 +713,9 @@ def insert_after(idx):
715713
def calculate_arrow_image_height(self):
716714
"""Calculate the height of the arrow image
717715
718-
Parameters
719-
----------
720-
feature_structure : list
721-
The feature structure
722-
723716
Returns
724717
-------
725-
int
718+
image_height : int
726719
The height of the arrow image
727720
"""
728721
image_height = 0
@@ -740,7 +733,7 @@ def build_feature_list_text(self):
740733
741734
Returns
742735
-------
743-
str
736+
content : str
744737
The feature list text
745738
"""
746739
content = "["

0 commit comments

Comments
 (0)