Commit 28b644acdace3bdf7d82af7a7606ecffadebb03e
1 parent
9ad187f4
Exists in
master
Using sizer to set crop dialog size
Showing
1 changed file
with
18 additions
and
22 deletions
Show diff stats
invesalius/gui/dialogs.py
| @@ -2693,23 +2693,14 @@ class FFillSegmentationOptionsDialog(wx.Dialog): | @@ -2693,23 +2693,14 @@ class FFillSegmentationOptionsDialog(wx.Dialog): | ||
| 2693 | class CropOptionsDialog(wx.Dialog): | 2693 | class CropOptionsDialog(wx.Dialog): |
| 2694 | 2694 | ||
| 2695 | def __init__(self, config): | 2695 | def __init__(self, config): |
| 2696 | - | ||
| 2697 | self.config = config | 2696 | self.config = config |
| 2698 | - | ||
| 2699 | pre = wx.PreDialog() | 2697 | pre = wx.PreDialog() |
| 2700 | 2698 | ||
| 2701 | - if sys.platform == 'win32': | ||
| 2702 | - size=wx.Size(204,165) | ||
| 2703 | - else: | ||
| 2704 | - size=wx.Size(205,180) | ||
| 2705 | - | ||
| 2706 | pre.Create(wx.GetApp().GetTopWindow(), -1, _(u"Crop mask"),\ | 2699 | pre.Create(wx.GetApp().GetTopWindow(), -1, _(u"Crop mask"),\ |
| 2707 | - size=size, style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT) | ||
| 2708 | - | 2700 | + style=wx.DEFAULT_DIALOG_STYLE|wx.FRAME_FLOAT_ON_PARENT) |
| 2709 | self.PostCreate(pre) | 2701 | self.PostCreate(pre) |
| 2710 | 2702 | ||
| 2711 | self._init_gui() | 2703 | self._init_gui() |
| 2712 | - #self.config = config | ||
| 2713 | 2704 | ||
| 2714 | def UpdateValues(self, pubsub_evt): | 2705 | def UpdateValues(self, pubsub_evt): |
| 2715 | 2706 | ||
| @@ -2730,19 +2721,17 @@ class CropOptionsDialog(wx.Dialog): | @@ -2730,19 +2721,17 @@ class CropOptionsDialog(wx.Dialog): | ||
| 2730 | self.tx_coronal_f.SetValue(str(yf)) | 2721 | self.tx_coronal_f.SetValue(str(yf)) |
| 2731 | 2722 | ||
| 2732 | def _init_gui(self): | 2723 | def _init_gui(self): |
| 2733 | - | ||
| 2734 | - | ||
| 2735 | p = wx.Panel(self, -1, style = wx.TAB_TRAVERSAL | 2724 | p = wx.Panel(self, -1, style = wx.TAB_TRAVERSAL |
| 2736 | | wx.CLIP_CHILDREN | 2725 | | wx.CLIP_CHILDREN |
| 2737 | | wx.FULL_REPAINT_ON_RESIZE) | 2726 | | wx.FULL_REPAINT_ON_RESIZE) |
| 2738 | - | 2727 | + |
| 2739 | gbs_principal = self.gbs = wx.GridBagSizer(4,1) | 2728 | gbs_principal = self.gbs = wx.GridBagSizer(4,1) |
| 2740 | 2729 | ||
| 2741 | gbs = self.gbs = wx.GridBagSizer(3, 4) | 2730 | gbs = self.gbs = wx.GridBagSizer(3, 4) |
| 2742 | - | 2731 | + |
| 2743 | flag_labels = wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL | 2732 | flag_labels = wx.ALIGN_RIGHT | wx.ALIGN_CENTER_VERTICAL |
| 2744 | 2733 | ||
| 2745 | - txt_style = wx.TE_READONLY | 2734 | + txt_style = wx.TE_READONLY |
| 2746 | 2735 | ||
| 2747 | stx_axial = wx.StaticText(p, -1, _(u"Axial:")) | 2736 | stx_axial = wx.StaticText(p, -1, _(u"Axial:")) |
| 2748 | self.tx_axial_i = tx_axial_i = wx.TextCtrl(p, -1, "", size=wx.Size(50,-1), style=txt_style) | 2737 | self.tx_axial_i = tx_axial_i = wx.TextCtrl(p, -1, "", size=wx.Size(50,-1), style=txt_style) |
| @@ -2751,7 +2740,7 @@ class CropOptionsDialog(wx.Dialog): | @@ -2751,7 +2740,7 @@ class CropOptionsDialog(wx.Dialog): | ||
| 2751 | 2740 | ||
| 2752 | gbs.Add(stx_axial, (0,0), flag=flag_labels) | 2741 | gbs.Add(stx_axial, (0,0), flag=flag_labels) |
| 2753 | gbs.Add(tx_axial_i, (0,1)) | 2742 | gbs.Add(tx_axial_i, (0,1)) |
| 2754 | - gbs.Add(stx_axial_t, (0,2), flag=flag_labels) | 2743 | + gbs.Add(stx_axial_t, (0,2), flag=flag_labels) |
| 2755 | gbs.Add(tx_axial_f, (0,3)) | 2744 | gbs.Add(tx_axial_f, (0,3)) |
| 2756 | 2745 | ||
| 2757 | stx_sagital = wx.StaticText(p, -1, _(u"Sagital:")) | 2746 | stx_sagital = wx.StaticText(p, -1, _(u"Sagital:")) |
| @@ -2761,7 +2750,7 @@ class CropOptionsDialog(wx.Dialog): | @@ -2761,7 +2750,7 @@ class CropOptionsDialog(wx.Dialog): | ||
| 2761 | 2750 | ||
| 2762 | gbs.Add(stx_sagital, (1,0), flag=flag_labels) | 2751 | gbs.Add(stx_sagital, (1,0), flag=flag_labels) |
| 2763 | gbs.Add(tx_sagital_i, (1,1)) | 2752 | gbs.Add(tx_sagital_i, (1,1)) |
| 2764 | - gbs.Add(stx_sagital_t, (1,2), flag=flag_labels) | 2753 | + gbs.Add(stx_sagital_t, (1,2), flag=flag_labels) |
| 2765 | gbs.Add(tx_sagital_f, (1,3)) | 2754 | gbs.Add(tx_sagital_f, (1,3)) |
| 2766 | 2755 | ||
| 2767 | stx_coronal = wx.StaticText(p, -1, _(u"Coronal:")) | 2756 | stx_coronal = wx.StaticText(p, -1, _(u"Coronal:")) |
| @@ -2771,11 +2760,11 @@ class CropOptionsDialog(wx.Dialog): | @@ -2771,11 +2760,11 @@ class CropOptionsDialog(wx.Dialog): | ||
| 2771 | 2760 | ||
| 2772 | gbs.Add(stx_coronal, (2,0), flag=flag_labels) | 2761 | gbs.Add(stx_coronal, (2,0), flag=flag_labels) |
| 2773 | gbs.Add(tx_coronal_i, (2,1)) | 2762 | gbs.Add(tx_coronal_i, (2,1)) |
| 2774 | - gbs.Add(stx_coronal_t, (2,2), flag=flag_labels) | 2763 | + gbs.Add(stx_coronal_t, (2,2), flag=flag_labels) |
| 2775 | gbs.Add(tx_coronal_f, (2,3)) | 2764 | gbs.Add(tx_coronal_f, (2,3)) |
| 2776 | 2765 | ||
| 2777 | gbs_button = wx.GridBagSizer(2, 4) | 2766 | gbs_button = wx.GridBagSizer(2, 4) |
| 2778 | - | 2767 | + |
| 2779 | btn_ok = self.btn_ok= wx.Button(p, wx.ID_OK) | 2768 | btn_ok = self.btn_ok= wx.Button(p, wx.ID_OK) |
| 2780 | btn_ok.SetDefault() | 2769 | btn_ok.SetDefault() |
| 2781 | 2770 | ||
| @@ -2791,11 +2780,18 @@ class CropOptionsDialog(wx.Dialog): | @@ -2791,11 +2780,18 @@ class CropOptionsDialog(wx.Dialog): | ||
| 2791 | 2780 | ||
| 2792 | box = wx.BoxSizer() | 2781 | box = wx.BoxSizer() |
| 2793 | box.AddSizer(gbs_principal, 1, wx.ALL|wx.EXPAND, 10) | 2782 | box.AddSizer(gbs_principal, 1, wx.ALL|wx.EXPAND, 10) |
| 2794 | - | 2783 | + |
| 2795 | p.SetSizer(box) | 2784 | p.SetSizer(box) |
| 2796 | - | 2785 | + box.Fit(p) |
| 2786 | + p.Layout() | ||
| 2787 | + | ||
| 2788 | + sizer = wx.BoxSizer() | ||
| 2789 | + sizer.Add(p, 1, wx.EXPAND) | ||
| 2790 | + sizer.Fit(self) | ||
| 2791 | + self.Layout() | ||
| 2792 | + | ||
| 2797 | Publisher.subscribe(self.UpdateValues, 'Update crop limits into gui') | 2793 | Publisher.subscribe(self.UpdateValues, 'Update crop limits into gui') |
| 2798 | - | 2794 | + |
| 2799 | btn_ok.Bind(wx.EVT_BUTTON, self.OnOk) | 2795 | btn_ok.Bind(wx.EVT_BUTTON, self.OnOk) |
| 2800 | btn_cancel.Bind(wx.EVT_BUTTON, self.OnClose) | 2796 | btn_cancel.Bind(wx.EVT_BUTTON, self.OnClose) |
| 2801 | self.Bind(wx.EVT_CLOSE, self.OnClose) | 2797 | self.Bind(wx.EVT_CLOSE, self.OnClose) |