Beispiel #1
0
    def __init__(self, parent):
        wx.Panel.__init__(self, parent)
        default_colour = self.GetBackgroundColour()
        backgroud_colour = wx.Colour(255, 255, 255)
        self.SetBackgroundColour(backgroud_colour)
        self.SetAutoLayout(1)

        BMP_ADD = wx.Bitmap("../icons/object_add.png", wx.BITMAP_TYPE_PNG)
        #BMP_ADD.SetWidth(25)
        #BMP_ADD.SetHeight(25)

        # Button for creating new surface
        button_new_surface = pbtn.PlateButton(self, BTN_NEW, "", BMP_ADD, style=\
                                   pbtn.PB_STYLE_SQUARE | pbtn.PB_STYLE_DEFAULT)
        button_new_surface.SetBackgroundColour(self.GetBackgroundColour())
        self.Bind(wx.EVT_BUTTON, self.OnButton)

        # Fixed hyperlink items
        tooltip = wx.ToolTip(_("Create 3D surface based on a mask"))
        link_new_surface = hl.HyperLinkCtrl(self, -1,
                                            _("Create new 3D surface"))
        link_new_surface.SetUnderlines(False, False, False)
        link_new_surface.SetBold(True)
        link_new_surface.SetColours("BLACK", "BLACK", "BLACK")
        link_new_surface.SetBackgroundColour(self.GetBackgroundColour())
        link_new_surface.SetToolTip(tooltip)
        link_new_surface.AutoBrowse(False)
        link_new_surface.UpdateLink()
        link_new_surface.Bind(hl.EVT_HYPERLINK_LEFT, self.OnLinkNewSurface)

        # Create horizontal sizers to represent lines in the panel
        line_new = wx.BoxSizer(wx.HORIZONTAL)
        line_new.Add(link_new_surface, 1,
                     wx.EXPAND | wx.GROW | wx.TOP | wx.RIGHT, 4)
        line_new.Add(button_new_surface, 0, wx.ALL | wx.EXPAND | wx.GROW, 0)

        # Folde panel which contains surface properties and quality
        fold_panel = FoldPanel(self)
        fold_panel.SetBackgroundColour(default_colour)

        # Button to fold to select region task
        button_next = wx.Button(self, -1, _("Next step"))
        if sys.platform != 'win32':
            button_next.SetWindowVariant(wx.WINDOW_VARIANT_SMALL)
        button_next.Bind(wx.EVT_BUTTON, self.OnButtonNextTask)

        # Add line sizers into main sizer
        main_sizer = wx.BoxSizer(wx.VERTICAL)
        main_sizer.Add(line_new, 0,
                       wx.GROW | wx.EXPAND | wx.LEFT | wx.RIGHT | wx.TOP, 5)
        main_sizer.Add(fold_panel, 0, wx.GROW | wx.EXPAND | wx.ALL, 5)
        main_sizer.Add(button_next, 0, wx.ALIGN_RIGHT | wx.RIGHT | wx.BOTTOM,
                       5)
        main_sizer.Fit(self)

        self.SetSizerAndFit(main_sizer)
        self.Update()
        #self.SetAutoLayout(1)

        self.sizer = main_sizer
Beispiel #2
0
    def __init__(self, parent):
        wx.Panel.__init__(self, parent)
        default_colour = wx.SystemSettings_GetColour(wx.SYS_COLOUR_MENUBAR)
        self.SetBackgroundColour(default_colour)

        #self.SetBackgroundColour(wx.Colour(255,255,255))
        self.SetAutoLayout(1)

        # Fixed hyperlink items
        tooltip = wx.ToolTip(
            _("Automatically select largest disconnected region and create new surface"
              ))
        link_largest = hl.HyperLinkCtrl(self, -1, _("Select largest surface"))
        link_largest.SetUnderlines(False, False, False)
        link_largest.SetColours("BLACK", "BLACK", "BLACK")
        link_largest.SetToolTip(tooltip)
        link_largest.AutoBrowse(False)
        link_largest.UpdateLink()
        link_largest.Bind(hl.EVT_HYPERLINK_LEFT, self.OnLinkLargest)

        tooltip = wx.ToolTip(
            _("Automatically select disconnected regions and create a new surface per region"
              ))
        link_split_all = hl.HyperLinkCtrl(self, -1,
                                          _("Split all disconnected surfaces"))
        link_split_all.SetUnderlines(False, False, False)
        link_split_all.SetColours("BLACK", "BLACK", "BLACK")
        link_split_all.SetToolTip(tooltip)
        link_split_all.AutoBrowse(False)
        link_split_all.UpdateLink()
        link_split_all.Bind(hl.EVT_HYPERLINK_LEFT, self.OnLinkSplit)

        tooltip = wx.ToolTip(
            _("Manually insert seeds of regions of interest and create a new surface"
              ))
        link_seeds = hl.HyperLinkCtrl(self, -1,
                                      _("Select regions of interest..."))
        link_seeds.SetUnderlines(False, False, False)
        link_seeds.SetColours("BLACK", "BLACK", "BLACK")
        link_seeds.SetToolTip(tooltip)
        link_seeds.AutoBrowse(False)
        link_seeds.UpdateLink()
        link_seeds.Bind(hl.EVT_HYPERLINK_LEFT, self.OnLinkSeed)

        # Image(s) for buttons
        img_largest = wx.Image("../icons/connectivity_largest.png",
                               wx.BITMAP_TYPE_PNG)
        img_largest.Rescale(25, 25)
        bmp_largest = img_largest.ConvertToBitmap()

        img_split_all = wx.Image("../icons/connectivity_split_all.png",
                                 wx.BITMAP_TYPE_PNG)
        img_split_all.Rescale(25, 25)
        bmp_split_all = img_split_all.ConvertToBitmap()

        img_seeds = wx.Image("../icons/connectivity_manual.png",
                             wx.BITMAP_TYPE_PNG)
        img_seeds.Rescale(25, 25)
        bmp_seeds = img_seeds.ConvertToBitmap()

        # Buttons related to hyperlinks
        button_style = pbtn.PB_STYLE_SQUARE | pbtn.PB_STYLE_DEFAULT
        button_style_plus = button_style | pbtn.PB_STYLE_TOGGLE

        button_split = pbtn.PlateButton(self,
                                        BTN_SPLIT,
                                        "",
                                        bmp_split_all,
                                        style=button_style)
        button_largest = pbtn.PlateButton(self,
                                          BTN_LARGEST,
                                          "",
                                          bmp_largest,
                                          style=button_style)
        button_seeds = pbtn.PlateButton(self,
                                        BTN_SEEDS,
                                        "",
                                        bmp_seeds,
                                        style=button_style_plus)

        self.button_seeds = button_seeds

        # When using PlaneButton, it is necessary to bind events from parent win
        self.Bind(wx.EVT_BUTTON, self.OnButton)

        # Tags and grid sizer for fixed items
        flag_link = wx.EXPAND | wx.GROW | wx.LEFT | wx.TOP
        flag_button = wx.EXPAND | wx.GROW

        #fixed_sizer = wx.FlexGridSizer(rows=3, cols=2, hgap=2, vgap=0)
        fixed_sizer = wx.FlexGridSizer(rows=3, cols=2, hgap=2, vgap=0)
        fixed_sizer.AddGrowableCol(0, 1)
        fixed_sizer.AddMany([(link_largest, 1, flag_link, 3),
                             (button_largest, 0, flag_button),
                             (link_seeds, 1, flag_link, 3),
                             (button_seeds, 0, flag_button),
                             (link_split_all, 1, flag_link, 3),
                             (button_split, 0, flag_button)])

        # Add line sizers into main sizer
        main_sizer = wx.BoxSizer(wx.VERTICAL)
        main_sizer.Add(fixed_sizer, 0, wx.GROW | wx.EXPAND | wx.TOP, 5)

        # Update main sizer and panel layout
        self.SetSizerAndFit(main_sizer)
        self.Update()
        self.sizer = main_sizer