def __init__(self, cruncher_selection_dialog): self.cruncher_selection_dialog = cruncher_selection_dialog wx.lib.scrolledpanel.ScrolledPanel.__init__(self, cruncher_selection_dialog) self.SetBackgroundColour(wx_tools.get_background_color()) self.SetMinSize((530, 300)) self.main_v_sizer = wx.BoxSizer(wx.VERTICAL) self.cruncher_text = wx.StaticText(self, label='') self.cruncher_text.Wrap(self._get_wrap_width()) self.main_v_sizer.Add(self.cruncher_text, 0, wx.EXPAND) self.main_v_sizer.AddSpacer((1, 20)) self.cruncher_unavailability_text = wx.StaticText(self, label='') self.cruncher_unavailability_text.Wrap(self._get_wrap_width()) self.cruncher_unavailability_text.SetForegroundColour( wx.Colour(170, 0, 0)) self.main_v_sizer.Add(self.cruncher_unavailability_text, 0, wx.EXPAND) #self.general_text.SetSize((self.ClientSize[0] - 20, -1)) #self.cruncher_text.Wrap( #self.ClientSize[0]# - self.cruncher_list_box.BestSize[0] - 20 #) #self.cruncher_text.SetSize(self.cruncher_text.GetEffectiveMinSize()) self.SetSizer(self.main_v_sizer) self.SetupScrolling()
def __init__(self, cruncher_selection_dialog): self.cruncher_selection_dialog = cruncher_selection_dialog wx.lib.scrolledpanel.ScrolledPanel.__init__(self, cruncher_selection_dialog) self.SetBackgroundColour(wx_tools.get_background_color()) self.SetMinSize((530, 300)) self.main_v_sizer = wx.BoxSizer(wx.VERTICAL) self.cruncher_text = wx.StaticText(self, label="") self.cruncher_text.Wrap(self._get_wrap_width()) self.main_v_sizer.Add(self.cruncher_text, 0, wx.EXPAND) self.main_v_sizer.AddSpacer((1, 20)) self.cruncher_unavailability_text = wx.StaticText(self, label="") self.cruncher_unavailability_text.Wrap(self._get_wrap_width()) self.cruncher_unavailability_text.SetForegroundColour(wx.Colour(170, 0, 0)) self.main_v_sizer.Add(self.cruncher_unavailability_text, 0, wx.EXPAND) # self.general_text.SetSize((self.ClientSize[0] - 20, -1)) # self.cruncher_text.Wrap( # self.ClientSize[0]# - self.cruncher_list_box.BestSize[0] - 20 # ) # self.cruncher_text.SetSize(self.cruncher_text.GetEffectiveMinSize()) self.SetSizer(self.main_v_sizer) self.SetupScrolling()
def __init__(self, argument_control, star_kwarg_box, name="", value=""): wx.Panel.__init__(self, argument_control) if wx.Platform == "__WXGTK__": self.SetBackgroundColour(wx_tools.get_background_color()) self.argument_control = argument_control self.star_kwarg_box = star_kwarg_box self.main_h_sizer = wx.BoxSizer(wx.HORIZONTAL) self.name_text_ctrl = NameTextCtrl(self, value=name) self.main_h_sizer.Add(self.name_text_ctrl, 4, wx.ALIGN_CENTER_VERTICAL) self.static_text = wx.StaticText(self, label=("=")) self.main_h_sizer.Add(self.static_text, 0, wx.ALIGN_CENTER_VERTICAL) self.value_text_ctrl = ValueTextCtrl(self, value=value) self.main_h_sizer.Add(self.value_text_ctrl, 6, wx.ALIGN_CENTER_VERTICAL) self.close_button = CloseButton(self) self.main_h_sizer.Add(self.close_button, 0, wx.ALIGN_CENTER_VERTICAL) self.SetSizer(self.main_h_sizer) self.Bind(wx.EVT_BUTTON, lambda event: self.remove(), source=self.close_button)
def __init__(self): aui.AuiDefaultDockArt.__init__(self) self.SetColor( aui.AUI_DOCKART_BACKGROUND_GRADIENT_COLOUR, self.GetColor( aui.AUI_DOCKART_BACKGROUND_COLOUR ) ) self.SetMetric(aui.AUI_DOCKART_SASH_SIZE, 2) font_size = 9 if wx.Platform == '__WXMAC__' else 7 self.SetMetric(aui.AUI_DOCKART_CAPTION_SIZE, 11) self.SetFont( aui.AUI_DOCKART_CAPTION_FONT, wx.Font(font_size, wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.NORMAL, False) ) #self.SetMetric(aui.AUI_DOCKART_GRADIENT_TYPE, # aui.AUI_GRADIENT_NONE) self.SetColor(aui.AUI_DOCKART_INACTIVE_CAPTION_COLOUR, wx_tools.get_background_color())
def __init__(self, argument_control, star_kwarg_box, name='', value=''): wx.Panel.__init__(self, argument_control) if wx.Platform == '__WXGTK__': self.SetBackgroundColour(wx_tools.get_background_color()) self.argument_control = argument_control self.star_kwarg_box = star_kwarg_box self.main_h_sizer = wx.BoxSizer(wx.HORIZONTAL) self.name_text_ctrl = NameTextCtrl(self, value=name) self.main_h_sizer.Add(self.name_text_ctrl, 4, wx.ALIGN_CENTER_VERTICAL) self.static_text = wx.StaticText(self, label=('=')) self.main_h_sizer.Add(self.static_text, 0, wx.ALIGN_CENTER_VERTICAL) self.value_text_ctrl = ValueTextCtrl(self, value=value) self.main_h_sizer.Add(self.value_text_ctrl, 6, wx.ALIGN_CENTER_VERTICAL) self.close_button = CloseButton(self) self.main_h_sizer.Add(self.close_button, 0, wx.ALIGN_CENTER_VERTICAL) self.SetSizer(self.main_h_sizer) self.Bind(wx.EVT_BUTTON, lambda event: self.remove(), source=self.close_button)
def __init__(self, argument_control, name, value=''): wx.Panel.__init__(self, argument_control) if wx.Platform == '__WXGTK__': self.SetBackgroundColour(wx_tools.get_background_color()) self.argument_control = argument_control self.name = name self.main_h_sizer = wx.BoxSizer(wx.HORIZONTAL) self.name_static_text = wx.StaticText(self, label=('%s=' % name)) self.main_h_sizer.Add(self.name_static_text, 0, wx.ALIGN_CENTER_VERTICAL) self.value_text_ctrl = ValueTextCtrl( self, #size=(100, -1), value=value ) self.main_h_sizer.Add(self.value_text_ctrl, 1, wx.ALIGN_CENTER_VERTICAL) self.SetSizer(self.main_h_sizer)
def __init__(self, *args, **kwargs): wx.Frame.__init__(self, *args, **kwargs) self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM) self.SetBackgroundColour(wx_tools.get_background_color()) self.SetDoubleBuffered(True) self.SetIcons(garlicsim_wx.misc.icon_bundle.get_icon_bundle()) self.Bind(wx.EVT_CLOSE, self.on_close) self.app = wx.GetApp() '''The GarlicSim `App` that created this frame.''' assert isinstance(self.app, garlicsim_wx.App) if hasattr(garlicsim_wx, '_active_frame'): warnings.warn('`garlicsim_wx` already had an `_active_frame` ' 'attribute before we created this frame! It should ' 'not have one.') garlicsim_wx._active_frame = self self.tree_browser = None self.seek_bar = None self.shell = None self.state_repr_viewer = None self.crunching_controls = None self.aui_manager = garlicsim_wx.misc.aui.AuiManager(self) '''The aui manager, which manages the workspace widgets.''' self.gui_project = None '''The current gui project.''' self.CreateStatusBar() self.__init_menus() self.__init_key_handlers() self.Bind(wx.EVT_CONTEXT_MENU, self.on_context_menu, self) self.background_timer = thread_timer.ThreadTimer(self) self.background_timer.start(150) self.Bind( thread_timer.EVT_THREAD_TIMER, lambda event: self.sync_crunchers(), self.background_timer ) self.aui_manager.Update() self.Show() self.Maximize()
def __init__(self, parent, frame, *args, **kwargs): self.frame = frame assert isinstance(self.frame, garlicsim_wx.Frame) self.gui_project = frame.gui_project assert isinstance(self.gui_project, garlicsim_wx.GuiProject) wx.Panel.__init__(self, parent, *args, **kwargs) self.SetBackgroundColour(wx_tools.get_background_color()) self.SetToolTipString('Add, remove or organize step profiles.') self.main_v_sizer = wx.BoxSizer(wx.VERTICAL) self.title_text = wx.StaticText(self, -1, 'Step profiles:') self.main_v_sizer.Add(self.title_text, 0, wx.ALL, 10) self.step_profiles_list = StepProfilesList(self, frame) self.main_v_sizer.Add(self.step_profiles_list, 1, wx.EXPAND | wx.BOTTOM, 8) self.button_h_sizer = wx.BoxSizer(wx.HORIZONTAL) self.main_v_sizer.Add(self.button_h_sizer, 0, wx.ALIGN_RIGHT) new_image = wx.BitmapFromImage( wx.ImageFromStream( pkg_resources.resource_stream(images_package, 'new.png'), wx.BITMAP_TYPE_ANY)) self.new_button = wx.BitmapButton(self, -1, new_image) self.new_button.SetToolTipString('Create a new step profile.') self.button_h_sizer.Add(self.new_button, 0, wx.RIGHT, 8) delete_image = wx.BitmapFromImage( wx.ImageFromStream( pkg_resources.resource_stream(images_package, 'trash.png'), wx.BITMAP_TYPE_ANY)) self.delete_button = wx.BitmapButton(self, -1, delete_image) self.delete_button.SetToolTipString( 'Delete the selected step profile.') self.delete_button.Disable() self.button_h_sizer.Add(self.delete_button, 0, wx.RIGHT, 8) self.SetSizer(self.main_v_sizer) self.Bind(wx.EVT_BUTTON, self.on_new_button, source=self.new_button) self.Bind(wx.EVT_BUTTON, self.on_delete_button, source=self.delete_button)
def make_bitmap(lightness=1, saturation=1): '''Make the bitmap of the color wheel.''' bitmap = wx.EmptyBitmap(BIG_LENGTH, BIG_LENGTH) assert isinstance(bitmap, wx.Bitmap) dc = wx.MemoryDC(bitmap) dc.SetBrush(wx_tools.get_background_brush()) dc.SetPen(wx.TRANSPARENT_PEN) dc.DrawRectangle(-5, -5, BIG_LENGTH + 10, BIG_LENGTH + 10) center_x = center_y = BIG_LENGTH // 2 background_color_rgb = wx_tools.wx_color_to_rgb( wx_tools.get_background_color() ) for x, y in cute_iter_tools.product(xrange(BIG_LENGTH), xrange(BIG_LENGTH)): # This is a big loop so the code is optimized to keep it fast. rx, ry = (x - center_x), (y - center_y) distance = (rx ** 2 + ry ** 2) ** 0.5 if (SMALL_RADIUS - AA_THICKNESS) <= distance <= \ (BIG_RADIUS + AA_THICKNESS): angle = -math.atan2(rx, ry) hue = (angle + math.pi) / two_pi rgb = colorsys.hls_to_rgb(hue, lightness, saturation) if abs(distance - RADIUS) > HALF_THICKNESS: # This pixel requires some anti-aliasing. if distance < RADIUS: aa_distance = SMALL_RADIUS - distance else: # distance > RADIUS aa_distance = distance - BIG_RADIUS aa_ratio = aa_distance / AA_THICKNESS rgb = color_tools.mix_rgb( aa_ratio, background_color_rgb, rgb ) color = wx_tools.rgb_to_wx_color(rgb) pen = wx.Pen(color) dc.SetPen(pen) dc.DrawPoint(x, y) return bitmap
def __init__(self, *args, **kwargs): wx.Frame.__init__(self, *args, **kwargs) self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM) self.SetBackgroundColour(wx_tools.get_background_color()) self.SetDoubleBuffered(True) self.SetIcons(garlicsim_wx.misc.icon_bundle.get_icon_bundle()) self.Bind(wx.EVT_CLOSE, self.on_close) self.app = wx.GetApp() '''The GarlicSim `App` that created this frame.''' assert isinstance(self.app, garlicsim_wx.App) if hasattr(garlicsim_wx, '_active_frame'): warnings.warn('`garlicsim_wx` already had an `_active_frame` ' 'attribute before we created this frame! It should ' 'not have one.') garlicsim_wx._active_frame = self self.tree_browser = None self.seek_bar = None self.shell = None self.state_repr_viewer = None self.crunching_controls = None self.aui_manager = garlicsim_wx.misc.aui.AuiManager(self) '''The aui manager, which manages the workspace widgets.''' self.gui_project = None '''The current gui project.''' self.CreateStatusBar() self.__init_menus() self.__init_key_handlers() self.Bind(wx.EVT_CONTEXT_MENU, self.on_context_menu, self) self.background_timer = thread_timer.ThreadTimer(self) self.background_timer.start(150) self.Bind(thread_timer.EVT_THREAD_TIMER, lambda event: self.sync_crunchers(), self.background_timer) self.aui_manager.Update() self.Show() self.Maximize()
def __init__(self, frame): wx.lib.scrolledpanel.ScrolledPanel.__init__(self, frame, -1, style=wx.SUNKEN_BORDER) WorkspaceWidget.__init__(self, frame) self.SetBackgroundColour(wx_tools.get_background_color()) self.SetupScrolling() assert isinstance(self.gui_project, garlicsim_wx.GuiProject) # I put this assert mainly for better source assistance in Wing. # It may be removed. self.Bind(wx.EVT_SIZE, self.on_size) self.Bind(wx.EVT_PAINT, self.on_paint) self.main_v_sizer = wx.BoxSizer(wx.VERTICAL) self.SetSizer(self.main_v_sizer) self.autocrunch_controls = AutocrunchControls(self, frame) self.main_v_sizer.Add(self.autocrunch_controls, 0, wx.ALL, border=10) self.step_profiles_controls = StepProfilesControls(self, frame) self.main_v_sizer.Add(self.step_profiles_controls, 1, wx.EXPAND | wx.ALL, border=10) self.horizontal_line = wx.StaticLine(self, -1) self.main_v_sizer.Add(self.horizontal_line, 0, wx.EXPAND | wx.LEFT | wx.RIGHT, border=30) self.main_v_sizer.AddSpacer((1, 20)) self.cruncher_controls = CruncherControls(self, frame) self.main_v_sizer.Add(self.cruncher_controls, 0, wx.EXPAND | wx.LEFT | wx.TOP | wx.RIGHT, 10) self.autocrunch_controls.SetFocus()
def __init__(self, argument_control, label): self.argument_control = argument_control wx.StaticText.__init__(self, argument_control, label=label, size=argument_control.box_size, style=wx.ALIGN_CENTER_HORIZONTAL) old_foreground_color = self.GetForegroundColour() faint_color = wx_tools.mix_wx_color(0.5, old_foreground_color, wx_tools.get_background_color()) self.SetForegroundColour(faint_color) self.SetMinSize(argument_control.box_size) self.SetMaxSize(argument_control.box_size)
def __init__(self, argument_control, label): self.argument_control = argument_control wx.StaticText.__init__(self, argument_control, label=label, size=argument_control.box_size, style=wx.ALIGN_CENTER_HORIZONTAL) old_foreground_color = self.GetForegroundColour() faint_color = wx_tools.mix_wx_color(0.5, old_foreground_color, wx_tools.get_background_color()) self.SetForegroundColour(faint_color) self.SetMinSize(argument_control.box_size) self.SetMaxSize(argument_control.box_size)
def __init__(self, step_profile_dialog, step_function=None): self.step_profile_dialog = step_profile_dialog self.gui_project = step_profile_dialog.gui_project wx.Panel.__init__(self, step_profile_dialog) self.SetBackgroundColour(wx_tools.get_background_color()) self.box_size = wx.Size(200, -1) if wx.Platform == '__WXMSW__' \ else wx.Size(250, -1) self.step_function = None self.main_h_sizer = wx.BoxSizer(wx.HORIZONTAL) self.SetSizer(self.main_h_sizer) self.set_step_function(step_function)
def __init__(self, step_profile_dialog, step_function=None): self.step_profile_dialog = step_profile_dialog self.gui_project = step_profile_dialog.gui_project wx.Panel.__init__(self, step_profile_dialog) self.SetBackgroundColour(wx_tools.get_background_color()) self.box_size = wx.Size(200, -1) if wx.Platform == '__WXMSW__' \ else wx.Size(250, -1) self.step_function = None self.main_h_sizer = wx.BoxSizer(wx.HORIZONTAL) self.SetSizer(self.main_h_sizer) self.set_step_function(step_function)
def __init__(self, frame): wx.lib.scrolledpanel.ScrolledPanel.__init__(self, frame, -1, style=wx.SUNKEN_BORDER) WorkspaceWidget.__init__(self, frame) self.SetBackgroundColour(wx_tools.get_background_color()) self.SetupScrolling() assert isinstance(self.gui_project, garlicsim_wx.GuiProject) # I put this assert mainly for better source assistance in Wing. # It may be removed. self.Bind(wx.EVT_SIZE, self.on_size) self.Bind(wx.EVT_PAINT, self.on_paint) self.main_v_sizer = wx.BoxSizer(wx.VERTICAL) self.SetSizer(self.main_v_sizer) self.autocrunch_controls = AutocrunchControls(self, frame) self.main_v_sizer.Add(self.autocrunch_controls, 0, wx.ALL, border=10) self.step_profiles_controls = StepProfilesControls(self, frame) self.main_v_sizer.Add(self.step_profiles_controls, 1, wx.EXPAND | wx.ALL, border=10) self.horizontal_line = wx.StaticLine(self, -1) self.main_v_sizer.Add(self.horizontal_line, 0, wx.EXPAND | wx.LEFT | wx.RIGHT, border=30) self.main_v_sizer.AddSpacer((1, 20)) self.cruncher_controls = CruncherControls(self, frame) self.main_v_sizer.Add(self.cruncher_controls, 0, wx.EXPAND | wx.LEFT | wx.TOP | wx.RIGHT, 10) self.autocrunch_controls.SetFocus()
def __init__(self): aui.AuiDefaultDockArt.__init__(self) self.SetColor(aui.AUI_DOCKART_BACKGROUND_GRADIENT_COLOUR, self.GetColor(aui.AUI_DOCKART_BACKGROUND_COLOUR)) self.SetMetric(aui.AUI_DOCKART_SASH_SIZE, 2) font_size = 9 if wx.Platform == '__WXMAC__' else 7 self.SetMetric(aui.AUI_DOCKART_CAPTION_SIZE, 11) self.SetFont( aui.AUI_DOCKART_CAPTION_FONT, wx.Font(font_size, wx.FONTFAMILY_DEFAULT, wx.NORMAL, wx.NORMAL, False)) #self.SetMetric(aui.AUI_DOCKART_GRADIENT_TYPE, # aui.AUI_GRADIENT_NONE) self.SetColor(aui.AUI_DOCKART_INACTIVE_CAPTION_COLOUR, wx_tools.get_background_color())
def __init__(self, parent, frame): assert isinstance(frame, garlicsim_wx.Frame) self.frame = frame self.gui_project = frame.gui_project wx.Panel.__init__(self, parent) self.SetBackgroundColour(wx_tools.get_background_color()) self.SetToolTipString('Observe or change the cruncher type that is ' 'used when crunching the simulation.') self.main_v_sizer = wx.BoxSizer(wx.VERTICAL) self.SetSizer(self.main_v_sizer) self.title_text = wx.StaticText(self, -1, 'Cruncher in use:') self.main_v_sizer.Add(self.title_text, 0) self.cruncher_in_use_static_text = wx.StaticText(self, -1, '') self.cruncher_in_use_static_text.SetFont( wx.Font(14, wx.MODERN, wx.NORMAL, wx.NORMAL) ) self.main_v_sizer.Add(self.cruncher_in_use_static_text, 0, wx.EXPAND | wx.ALL, 5) self.change_cruncher_button = wx.Button(self, -1, 'Change...') self.Bind(wx.EVT_BUTTON, self.on_change_cruncher_button, self.change_cruncher_button) self.main_v_sizer.Add(self.change_cruncher_button, 0, wx.ALIGN_RIGHT | wx.BOTTOM, 5) self.gui_project.cruncher_type_changed_emitter.add_output( self._recalculate )
def __init__(self, frame): wx.Panel.__init__(self, frame, size=(100, 100), style=wx.SUNKEN_BORDER) WorkspaceWidget.__init__(self, frame) self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM) self.SetBackgroundColour(wx_tools.get_background_color()) self.Bind(wx.EVT_PAINT, self.on_paint) self.Bind(wx.EVT_SIZE, self.on_size) self.Bind(wx.EVT_MOUSE_EVENTS, self.on_mouse_event) self.Bind(wx.EVT_KEY_DOWN, self.on_key_down) self.zoom = 1. self.start = 0. self.screenify = lambda x: (x-self.start)*self.zoom '''Translate from time point to on-screen coordinate.''' self.unscreenify = lambda x: (x/self.zoom)+self.start '''Translate from on-screen coordinate to time point.''' self.was_playing_before_mouse_click = None self.was_playing_before_mouse_click_but_then_paused_and_mouse_left = \ None self.active_triangle_width = 13 # Must be odd number self.view_changed_flag = False self.active_node_changed_or_modified_flag = False self.path_contents_changed_flag = False self.view_change_emitter = emitters.Emitter() self.gui_project.active_node_changed_or_modified_emitter.add_output( FlagRaiser(self, 'active_node_changed_or_modified_flag') ) self.gui_project.path_contents_changed_emitter.add_output( FlagRaiser(self, 'path_contents_changed_flag') )
def __init__(self, parent, frame): assert isinstance(frame, garlicsim_wx.Frame) self.frame = frame self.gui_project = frame.gui_project wx.Panel.__init__(self, parent) self.SetBackgroundColour(wx_tools.get_background_color()) self.SetToolTipString('Observe or change the cruncher type that is ' 'used when crunching the simulation.') self.main_v_sizer = wx.BoxSizer(wx.VERTICAL) self.SetSizer(self.main_v_sizer) self.title_text = wx.StaticText(self, -1, 'Cruncher in use:') self.main_v_sizer.Add(self.title_text, 0) self.cruncher_in_use_static_text = wx.StaticText(self, -1, '') self.cruncher_in_use_static_text.SetFont( wx.Font(14, wx.MODERN, wx.NORMAL, wx.NORMAL)) self.main_v_sizer.Add(self.cruncher_in_use_static_text, 0, wx.EXPAND | wx.ALL, 5) self.change_cruncher_button = wx.Button(self, -1, 'Change...') self.Bind(wx.EVT_BUTTON, self.on_change_cruncher_button, self.change_cruncher_button) self.main_v_sizer.Add(self.change_cruncher_button, 0, wx.ALIGN_RIGHT | wx.BOTTOM, 5) self.gui_project.cruncher_type_changed_emitter.add_output( self._recalculate)
def __init__(self, hue_selection_dialog): wx.Panel.__init__(self, parent=hue_selection_dialog, size=(75, 100)) self.SetBackgroundColour(wx_tools.get_background_color()) self.hue_selection_dialog = hue_selection_dialog self.hue = hue_selection_dialog.hue self.frozen = 0 self.freezer = Freezer(self) self.main_v_sizer = wx.BoxSizer(wx.VERTICAL) self.hue_static_text = wx.StaticText(self, label='Hue:') self.main_v_sizer.Add(self.hue_static_text, 0, wx.ALIGN_LEFT | wx.BOTTOM, border=5) self.h_sizer = wx.BoxSizer(wx.HORIZONTAL) self.main_v_sizer.Add(self.h_sizer, 0) self.spin_ctrl = wx.SpinCtrl(self, min=0, max=359, initial=ratio_to_round_degrees(self.hue), size=(70, -1), style=wx.SP_WRAP) if wx.Platform == '__WXMAC__': self.spin_ctrl.SetValue(ratio_to_round_degrees(self.hue)) self.h_sizer.Add(self.spin_ctrl, 0) self.degree_static_text = wx.StaticText(self, label=unichr(176)) self.h_sizer.Add(self.degree_static_text, 0) self.SetSizerAndFit(self.main_v_sizer) self.Bind(wx.EVT_SPINCTRL, self.on_spin, source=self.spin_ctrl) self.Bind(wx.EVT_TEXT, self.on_text, source=self.spin_ctrl)
def __init__(self, step_profile_dialog, step_function=None): self.step_profile_dialog = step_profile_dialog self.width = 400 if wx.Platform == '__WXMSW__' else 500 self.step_function = None wx.Panel.__init__(self, step_profile_dialog) self.SetBackgroundColour(wx_tools.get_background_color()) self.text = wx.StaticText(self, style=wx.ALIGN_CENTER_HORIZONTAL) self.SetMinSize((self.width, 25)) #self.SetBackgroundColour(wx_tools.get_background_color()) self.text.Wrap(self.width - 10) self.Bind(wx.EVT_SIZE, self.on_size) self.main_h_sizer = wx.BoxSizer(wx.HORIZONTAL) self.v_sizer = wx.BoxSizer(wx.VERTICAL) self.main_h_sizer.Add(self.v_sizer, 1, wx.ALIGN_CENTER_VERTICAL) self.v_sizer.Add(self.text, 0, wx.ALIGN_CENTER_HORIZONTAL) self.SetSizer(self.main_h_sizer) self._error_color = wx.Colour(255, 200, 200) self._success_color = wx.Colour(200, 255, 200) self.valid_step_function = True
def __init__(self, step_profile_dialog, step_function=None): self.step_profile_dialog = step_profile_dialog self.width = 400 if wx.Platform == '__WXMSW__' else 500 self.step_function = None wx.Panel.__init__(self, step_profile_dialog) self.SetBackgroundColour(wx_tools.get_background_color()) self.text = wx.StaticText(self, style=wx.ALIGN_CENTER_HORIZONTAL) self.SetMinSize((self.width, 25)) #self.SetBackgroundColour(wx_tools.get_background_color()) self.text.Wrap(self.width - 10) self.Bind(wx.EVT_SIZE, self.on_size) self.main_h_sizer = wx.BoxSizer(wx.HORIZONTAL) self.v_sizer = wx.BoxSizer(wx.VERTICAL) self.main_h_sizer.Add(self.v_sizer, 1, wx.ALIGN_CENTER_VERTICAL) self.v_sizer.Add(self.text, 0, wx.ALIGN_CENTER_HORIZONTAL) self.SetSizer(self.main_h_sizer) self._error_color = wx.Colour(255, 200, 200) self._success_color = wx.Colour(200, 255, 200) self.valid_step_function = True
def __init__(self, frame): wx.Panel.__init__(self, frame, -1, size=(184, 128), style=wx.SUNKEN_BORDER) WorkspaceWidget.__init__(self, frame) #self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM) self.SetBackgroundColour(wx_tools.get_background_color()) self.SetDoubleBuffered(True) assert isinstance(self.gui_project, garlicsim_wx.GuiProject) # I put this assert mainly for better source assistance in Wing. # It may be removed. self.Bind(wx.EVT_SIZE, self.on_size) self.Bind(wx.EVT_PAINT, self.on_paint) self.inner_panel = wx.Panel(self, -1, size=(184, 124)) '''The panel that contains all the subwidgets.''' self.inner_panel.SetBackgroundColour(wx_tools.get_background_color()) self.center_button_mode = PlayMode '''The current mode of the center button.''' bitmap_list = ['to_start', 'previous_node', 'play', 'next_node', 'to_end', 'pause', 'finalize'] bitmaps_dict = self.bitmap_dict = {} for bitmap_name in bitmap_list: stream = pkg_resources.resource_stream(images_package, bitmap_name + '.png') self.bitmap_dict[bitmap_name] = wx.BitmapFromImage( wx.ImageFromStream( stream, wx.BITMAP_TYPE_ANY ) ) self.center_button_bitmap_dict = { PlayMode: bitmaps_dict['play'], PauseMode: bitmaps_dict['pause'], FinalizeMode: bitmaps_dict['finalize'], } v_sizer = self.v_sizer = wx.BoxSizer(wx.VERTICAL) playing_speed_getter = lambda: \ self.gui_project.official_playing_speed / \ self.gui_project.standard_playing_speed playing_speed_setter = lambda value: \ self.gui_project.set_official_playing_speed( value * self.gui_project.standard_playing_speed ) self.playing_speed_knob = Knob( self.inner_panel, getter = playing_speed_getter, setter = playing_speed_setter ) '''Knob which controls the official playback speed.''' self.playing_speed_knob.set_snap_point(-1) self.playing_speed_knob.set_snap_point(1) self.knob_sizer = knob_sizer = wx.BoxSizer(wx.HORIZONTAL) knob_sizer.Add( self.playing_speed_knob, 1, wx.EXPAND | wx.ALIGN_CENTER_HORIZONTAL |\ wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 75 ) v_sizer.Add( knob_sizer, #self.playing_speed_knob, # knob_sizer, 0, #wx.ALIGN_CENTER_HORIZONTAL #wx.EXPAND #| ) h_sizer = wx.BoxSizer(wx.HORIZONTAL) self.button_to_start = wx.BitmapButton( self.inner_panel, -1, bitmaps_dict['to_start'], size=(31, 50) ) '''Button for moving to start of path.''' self.button_previous_node = wx.BitmapButton( self.inner_panel, -1, bitmaps_dict['previous_node'], size=(31, 50) ) '''Button for moving to previous node.''' self.button_center_button = wx.BitmapButton( self.inner_panel, -1, bitmaps_dict['play'], size=(60, 50) ) '''Button for playing/pausing playback, and finalizing edited node.''' self.button_next_node= wx.BitmapButton( self.inner_panel, -1, bitmaps_dict['next_node'], size=(31, 50) ) '''Button for moving to next node.''' self.button_to_end = wx.BitmapButton( self.inner_panel, -1, bitmaps_dict['to_end'], size=(31, 50) ) '''Button for moving to end of path.''' self.Bind(wx.EVT_BUTTON, self.on_button_to_start, source=self.button_to_start) self.Bind(wx.EVT_BUTTON, self.on_button_previous_node, source=self.button_previous_node) self.Bind(wx.EVT_BUTTON, self.on_button_center_button, source=self.button_center_button) self.Bind(wx.EVT_BUTTON, self.on_button_next_node, source=self.button_next_node) self.Bind(wx.EVT_BUTTON, self.on_button_to_end, source=self.button_to_end) button_line = ( self.button_to_start, self.button_previous_node, self.button_center_button, self.button_next_node, self.button_to_end ) for button in button_line: h_sizer.Add(button, 0) v_sizer.Add(h_sizer, 0)#1, wx.EXPAND) self.scratch_wheel = ScratchWheel(self.inner_panel, self.gui_project, -1, size=(184, 44)) v_sizer.Add(self.scratch_wheel, 0) self.inner_panel.SetSizer(v_sizer) knob_sizer.Layout() h_sizer.Layout() v_sizer.Layout() self.center_button_update_flag = True '''Flag saying whether the center button needs update.''' self.navigation_buttons_update_flag = True '''Flag saying whether the navigation buttons need update.''' self.playing_speed_knob_update_flag = True '''Flag saying whether the playing speed knob needs update.''' self.center_button_needs_update_emitter = \ self.gui_project.emitter_system.make_emitter( inputs=( self.gui_project.playing_toggled_emitter, self.gui_project.active_node_changed_or_modified_emitter, self.gui_project.active_node_finalized_emitter ), outputs=( FlagRaiser(self, 'center_button_update_flag', function=self._update_center_button, delay=0.03), ), name='playback_controls_center_button_needs_update', ) self.navigation_buttons_need_update_emitter = \ self.gui_project.emitter_system.make_emitter( inputs=( self.gui_project.active_node_changed_emitter, self.gui_project.path_contents_changed_emitter ), outputs=( FlagRaiser( self, 'navigation_buttons_update_flag', function=self._update_navigation_buttons, delay=0.03 ), ), name='playback_controls_navigation_buttons_need_update', ) self.gui_project.official_playing_speed_modified_emitter.add_output( FlagRaiser(self.playing_speed_knob, 'recalculation_flag', self.playing_speed_knob._recalculate, delay=0.03) )
def __init__(self, parent, frame): assert isinstance(frame, garlicsim_wx.Frame) self.frame = frame self.gui_project = frame.gui_project assert isinstance(self.gui_project, garlicsim_wx.GuiProject) wx.Panel.__init__(self, parent, -1) self.SetBackgroundColour(wx_tools.get_background_color()) tooltip_text = ('Set the clock buffer that will be crunched ' 'automatically from the active node.') self.SetToolTipString(tooltip_text) self.frozen = 0 self.freezer = Freezer(self) self.main_h_sizer = wx.BoxSizer(wx.HORIZONTAL) self.SetSizer(self.main_h_sizer) self.check_box = wx.CheckBox(self, -1, 'Autocrunch: ') self.check_box.SetToolTipString(tooltip_text) self.main_h_sizer.Add( self.check_box, 0, wx.EXPAND | wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, border=10 ) self.spin_ctrl = wx.SpinCtrl(self, -1, max=10000000) self.spin_ctrl.SetToolTipString(tooltip_text) self.main_h_sizer.Add(self.spin_ctrl, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT) self.check_box.SetValue( bool(self.gui_project.default_buffer) ) self.spin_ctrl.Enable( bool(self.gui_project.default_buffer) ) self.spin_ctrl.SetValue( self.gui_project.default_buffer or \ self.gui_project._default_buffer_before_cancellation or \ 0 ) ### Setting up event handling and emitter connections: ################ # # self.gui_project.default_buffer_modified_emitter.add_output( self.update_check_box ) self.Bind(wx.EVT_CHECKBOX, self.on_check_box, source=self.check_box) self.Bind(wx.EVT_SPINCTRL, self.on_spin, self.spin_ctrl) self.Bind(wx.EVT_TEXT, self.on_text, self.spin_ctrl) self.gui_project.default_buffer_modified_emitter.add_output( self.update_spin_ctrl )
def __init__(self, frame): # todo: on mouse drag should pause like seek bar does ScrolledPanel.__init__(self, frame, size=(100, 100), style=wx.SUNKEN_BORDER) WorkspaceWidget.__init__(self, frame) self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM) self.SetBackgroundColour(wx_tools.get_background_color()) self.SetupScrolling() #self.SetScrollRate(20,20) #self.sizer=wx.BoxSizer(wx.VERTICAL) #self.panel=wx.StaticBitmap(self,-1,wx.Bitmap("images\\snail.gif", wx.BITMAP_TYPE_ANY))#wx.Panel(self,-1,size=(-1,200))#wx.TextCtrl(self, -1, size=(-1,200), style=wx.TE_MULTILINE) #self.panel=wx.Panel(self,-1,size=(-1,100)) #self.sizer.Add(self.panel,1,wx.EXPAND) #self.SetSizer(self.sizer) #self.EnableScrolling(True, True) #self.SetScrollbars(5, 30, 1055, 40) #self.sizer.Fit(self) #self.Centre() #self.SetVirtualSize((1000,1000)) self.Bind(wx.EVT_PAINT, self.on_paint) self.Bind(wx.EVT_SIZE, self.on_size) self.Bind(wx.EVT_MOUSE_EVENTS, self.on_mouse_event) self.Bind(wx.EVT_KEY_DOWN, self.on_key_down) self.tree_remapping_flag = False self.recalculation_flag = False self.needs_tree_remapping_emitter = \ self.gui_project.emitter_system.make_emitter( inputs=( self.gui_project.tree_structure_modified_emitter, ), outputs=( FlagRaiser(self, 'tree_remapping_flag'), ), name='needs_tree_remapping', ) self.needs_recalculation_emitter = \ self.gui_project.emitter_system.make_emitter( inputs=( self.needs_tree_remapping_emitter, self.gui_project.step_profiles_to_hues_modified_emitter, self.gui_project.active_node_changed_or_modified_emitter, self.gui_project.tree_modified_on_path_emitter, # Note that if there's a non-structure tree change not on # the path it won't affect us. ), outputs=( FlagRaiser(self, 'recalculation_flag'), ), name='needs_recalculation', ) self.clickable_map = {} elements_raw = { 'Untouched': 'graysquare.png', 'Touched': 'graystar.png', 'Unfinalized Touched': 'grayunfinalizedstar.png', 'Untouched End': 'grayendsquare.png', 'Touched End': 'grayendstar.png', 'Block': 'grayblock.png', 'Active Untouched': 'orangesquare.png', 'Active Touched': 'orangestar.png', 'Active Unfinalized Touched': 'orangeunfinalizedstar.png', 'Active Untouched End': 'orangeendsquare.png', 'Active Touched End': 'orangeendstar.png', 'Active Block': 'orangeblock.png', } self.elements = {} for key in elements_raw: stream = pkg_resources.resource_stream(images_package, elements_raw[key]) self.elements[key] = wx.BitmapFromImage( wx.ImageFromStream( stream, wx.BITMAP_TYPE_ANY ) )
def __init__(self, frame): wx.Dialog.__init__(self, frame, title='About GarlicSim', size=(628, 600)) CuteDialog.__init__(self, frame, skip_dialog_init=True) self.SetDoubleBuffered(True) self.frame = frame v_sizer = wx.BoxSizer(wx.VERTICAL) self._original_image = wx.ImageFromStream( pkg_resources.resource_stream( images_package, 'about.png' ) ) self.bitmap_viewer = BitmapViewer(self, size=(627, 271)) v_sizer.Add(self.bitmap_viewer, 0) self.html_window = wx.html.HtmlWindow(self, size=(628, 270)) v_sizer.Add(self.html_window, 0) foreground_color_in_hex = \ wx_tools.wx_color_to_html_color(wx_tools.get_background_color()) background_color_in_hex = \ wx_tools.wx_color_to_html_color(wx.Colour(0, 0, 0)) self.html_window.SetPage( ''' <html> <body bgcolor="%s" color="%s"> <div align="center"> <font size="1"> © 2009-2011 Ram Rachum (a.k.a. cool-RR) <br /> This program is distributed under the LGPL2.1 license. <br /> </font></div> <div> GarlicSim is a platform for writing, running and analyzing computer simulations. It is general enough to handle any kind of simulation: Physics, game theory, epidemic spread, electronics, etc.<br /> <font size="1"><br /></font> <b> Version %s</b> Website: <a href="http://garlicsim.org">http://garlicsim.org</a> </div> <div> <font size="1"><br /></font> I would like to thank the open source community for making this program possible. This includes the developers of Python, Psyco, wxPython, wxWidgets, Mayavi, git, and so many others... And more thanks to the many people who spent many hours helping me out with various issues, on mailing lists such as wxpython-users and on the StackOverflow website. </div> </body> </html> ''' % ( foreground_color_in_hex, background_color_in_hex, garlicsim_wx.__version__ ) ) self.html_window.Bind( wx.html.EVT_HTML_LINK_CLICKED, lambda event: webbrowser.open_new_tab( event.GetLinkInfo().GetHref() ), self.html_window ) self.button_sizer = button_sizer = wx.StdDialogButtonSizer() self.ok_button = wx.Button(self, wx.ID_OK, "Let's get back to simulating!") self.ok_button.SetDefault() button_sizer.SetAffirmativeButton(self.ok_button) self.Bind(wx.EVT_BUTTON, self.on_ok, self.ok_button) button_sizer.AddButton(self.ok_button) button_sizer.Realize() button_sizer.SetMinSize((500, -1)) v_sizer.Add(button_sizer, 0) self.SetSizer(v_sizer) self.Layout() self.timer = garlicsim_wx.general_misc.cute_timer.CuteTimer(self) self.timer.Start(40, oneShot=True) self.Bind(wx.EVT_TIMER, self.on_timer, self.timer) self._rotate_image_hue()
def __init__(self, frame): # todo: on mouse drag should pause like seek bar does ScrolledPanel.__init__(self, frame, size=(100, 100), style=wx.SUNKEN_BORDER) WorkspaceWidget.__init__(self, frame) self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM) self.SetBackgroundColour(wx_tools.get_background_color()) self.SetupScrolling() #self.SetScrollRate(20,20) #self.sizer=wx.BoxSizer(wx.VERTICAL) #self.panel=wx.StaticBitmap(self,-1,wx.Bitmap("images\\snail.gif", wx.BITMAP_TYPE_ANY))#wx.Panel(self,-1,size=(-1,200))#wx.TextCtrl(self, -1, size=(-1,200), style=wx.TE_MULTILINE) #self.panel=wx.Panel(self,-1,size=(-1,100)) #self.sizer.Add(self.panel,1,wx.EXPAND) #self.SetSizer(self.sizer) #self.EnableScrolling(True, True) #self.SetScrollbars(5, 30, 1055, 40) #self.sizer.Fit(self) #self.Centre() #self.SetVirtualSize((1000,1000)) self.Bind(wx.EVT_PAINT, self.on_paint) self.Bind(wx.EVT_SIZE, self.on_size) self.Bind(wx.EVT_MOUSE_EVENTS, self.on_mouse_event) self.Bind(wx.EVT_KEY_DOWN, self.on_key_down) self.tree_remapping_flag = False self.recalculation_flag = False self.needs_tree_remapping_emitter = \ self.gui_project.emitter_system.make_emitter( inputs=( self.gui_project.tree_structure_modified_emitter, ), outputs=( FlagRaiser(self, 'tree_remapping_flag'), ), name='needs_tree_remapping', ) self.needs_recalculation_emitter = \ self.gui_project.emitter_system.make_emitter( inputs=( self.needs_tree_remapping_emitter, self.gui_project.step_profiles_to_hues_modified_emitter, self.gui_project.active_node_changed_or_modified_emitter, self.gui_project.tree_modified_on_path_emitter, # Note that if there's a non-structure tree change not on # the path it won't affect us. ), outputs=( FlagRaiser(self, 'recalculation_flag'), ), name='needs_recalculation', ) self.clickable_map = {} elements_raw = { 'Untouched': 'graysquare.png', 'Touched': 'graystar.png', 'Unfinalized Touched': 'grayunfinalizedstar.png', 'Untouched End': 'grayendsquare.png', 'Touched End': 'grayendstar.png', 'Block': 'grayblock.png', 'Active Untouched': 'orangesquare.png', 'Active Touched': 'orangestar.png', 'Active Unfinalized Touched': 'orangeunfinalizedstar.png', 'Active Untouched End': 'orangeendsquare.png', 'Active Touched End': 'orangeendstar.png', 'Active Block': 'orangeblock.png', } self.elements = {} for key in elements_raw: stream = pkg_resources.resource_stream(images_package, elements_raw[key]) self.elements[key] = wx.BitmapFromImage( wx.ImageFromStream(stream, wx.BITMAP_TYPE_ANY))
def __init__(self, *args, **kwargs): if not kwargs.pop('skip_dialog_init', False): wx.Dialog.__init__(self, *args, **kwargs) self.SetBackgroundColour(wx_tools.get_background_color())
def __init__(self, parent, frame, *args, **kwargs): self.frame = frame assert isinstance(self.frame, garlicsim_wx.Frame) self.gui_project = frame.gui_project assert isinstance(self.gui_project, garlicsim_wx.GuiProject) wx.Panel.__init__(self, parent, *args, **kwargs) self.SetBackgroundColour(wx_tools.get_background_color()) self.SetToolTipString('Add, remove or organize step profiles.') self.main_v_sizer = wx.BoxSizer(wx.VERTICAL) self.title_text = wx.StaticText(self, -1, 'Step profiles:') self.main_v_sizer.Add(self.title_text, 0, wx.ALL, 10) self.step_profiles_list = StepProfilesList(self, frame) self.main_v_sizer.Add(self.step_profiles_list, 1, wx.EXPAND | wx.BOTTOM, 8) self.button_h_sizer = wx.BoxSizer(wx.HORIZONTAL) self.main_v_sizer.Add(self.button_h_sizer, 0, wx.ALIGN_RIGHT) new_image = wx.BitmapFromImage( wx.ImageFromStream( pkg_resources.resource_stream(images_package, 'new.png'), wx.BITMAP_TYPE_ANY ) ) self.new_button = wx.BitmapButton(self, -1, new_image) self.new_button.SetToolTipString('Create a new step profile.') self.button_h_sizer.Add(self.new_button, 0, wx.RIGHT, 8) delete_image = wx.BitmapFromImage( wx.ImageFromStream( pkg_resources.resource_stream(images_package, 'trash.png'), wx.BITMAP_TYPE_ANY ) ) self.delete_button = wx.BitmapButton(self, -1, delete_image) self.delete_button.SetToolTipString( 'Delete the selected step profile.' ) self.delete_button.Disable() self.button_h_sizer.Add(self.delete_button, 0, wx.RIGHT, 8) self.SetSizer(self.main_v_sizer) self.Bind(wx.EVT_BUTTON, self.on_new_button, source=self.new_button) self.Bind(wx.EVT_BUTTON, self.on_delete_button, source=self.delete_button)
def __init__(self, frame): wx.Dialog.__init__(self, frame, title='About GarlicSim', size=(628, 600)) CuteDialog.__init__(self, frame, skip_dialog_init=True) self.SetDoubleBuffered(True) self.frame = frame v_sizer = wx.BoxSizer(wx.VERTICAL) self._original_image = wx.ImageFromStream( pkg_resources.resource_stream(images_package, 'about.png')) self.bitmap_viewer = BitmapViewer(self, size=(627, 271)) v_sizer.Add(self.bitmap_viewer, 0) self.html_window = wx.html.HtmlWindow(self, size=(628, 270)) v_sizer.Add(self.html_window, 0) foreground_color_in_hex = \ wx_tools.wx_color_to_html_color(wx_tools.get_background_color()) background_color_in_hex = \ wx_tools.wx_color_to_html_color(wx.Colour(0, 0, 0)) self.html_window.SetPage(''' <html> <body bgcolor="%s" color="%s"> <div align="center"> <font size="1"> © 2009-2011 Ram Rachum (a.k.a. cool-RR) <br /> This program is distributed under the LGPL2.1 license. <br /> </font></div> <div> GarlicSim is a platform for writing, running and analyzing computer simulations. It is general enough to handle any kind of simulation: Physics, game theory, epidemic spread, electronics, etc.<br /> <font size="1"><br /></font> <b> Version %s</b> Website: <a href="http://garlicsim.org">http://garlicsim.org</a> </div> <div> <font size="1"><br /></font> I would like to thank the open source community for making this program possible. This includes the developers of Python, Psyco, wxPython, wxWidgets, Mayavi, git, and so many others... And more thanks to the many people who spent many hours helping me out with various issues, on mailing lists such as wxpython-users and on the StackOverflow website. </div> </body> </html> ''' % (foreground_color_in_hex, background_color_in_hex, garlicsim_wx.__version__)) self.html_window.Bind( wx.html.EVT_HTML_LINK_CLICKED, lambda event: webbrowser.open_new_tab(event.GetLinkInfo().GetHref( )), self.html_window) self.button_sizer = button_sizer = wx.StdDialogButtonSizer() self.ok_button = wx.Button(self, wx.ID_OK, "Let's get back to simulating!") self.ok_button.SetDefault() button_sizer.SetAffirmativeButton(self.ok_button) self.Bind(wx.EVT_BUTTON, self.on_ok, self.ok_button) button_sizer.AddButton(self.ok_button) button_sizer.Realize() button_sizer.SetMinSize((500, -1)) v_sizer.Add(button_sizer, 0) self.SetSizer(v_sizer) self.Layout() self.timer = garlicsim_wx.general_misc.cute_timer.CuteTimer(self) self.timer.Start(40, oneShot=True) self.Bind(wx.EVT_TIMER, self.on_timer, self.timer) self._rotate_image_hue()
def __init__(self, frame): wx.Panel.__init__(self, frame, -1, size=(184, 128), style=wx.SUNKEN_BORDER) WorkspaceWidget.__init__(self, frame) #self.SetBackgroundStyle(wx.BG_STYLE_CUSTOM) self.SetBackgroundColour(wx_tools.get_background_color()) self.SetDoubleBuffered(True) assert isinstance(self.gui_project, garlicsim_wx.GuiProject) # I put this assert mainly for better source assistance in Wing. # It may be removed. self.Bind(wx.EVT_SIZE, self.on_size) self.Bind(wx.EVT_PAINT, self.on_paint) self.inner_panel = wx.Panel(self, -1, size=(184, 124)) '''The panel that contains all the subwidgets.''' self.inner_panel.SetBackgroundColour(wx_tools.get_background_color()) self.center_button_mode = PlayMode '''The current mode of the center button.''' bitmap_list = [ 'to_start', 'previous_node', 'play', 'next_node', 'to_end', 'pause', 'finalize' ] bitmaps_dict = self.bitmap_dict = {} for bitmap_name in bitmap_list: stream = pkg_resources.resource_stream(images_package, bitmap_name + '.png') self.bitmap_dict[bitmap_name] = wx.BitmapFromImage( wx.ImageFromStream(stream, wx.BITMAP_TYPE_ANY)) self.center_button_bitmap_dict = { PlayMode: bitmaps_dict['play'], PauseMode: bitmaps_dict['pause'], FinalizeMode: bitmaps_dict['finalize'], } v_sizer = self.v_sizer = wx.BoxSizer(wx.VERTICAL) playing_speed_getter = lambda: \ self.gui_project.official_playing_speed / \ self.gui_project.standard_playing_speed playing_speed_setter = lambda value: \ self.gui_project.set_official_playing_speed( value * self.gui_project.standard_playing_speed ) self.playing_speed_knob = Knob(self.inner_panel, getter=playing_speed_getter, setter=playing_speed_setter) '''Knob which controls the official playback speed.''' self.playing_speed_knob.set_snap_point(-1) self.playing_speed_knob.set_snap_point(1) self.knob_sizer = knob_sizer = wx.BoxSizer(wx.HORIZONTAL) knob_sizer.Add( self.playing_speed_knob, 1, wx.EXPAND | wx.ALIGN_CENTER_HORIZONTAL |\ wx.ALIGN_CENTER_VERTICAL | wx.LEFT, 75 ) v_sizer.Add( knob_sizer, #self.playing_speed_knob, # knob_sizer, 0, #wx.ALIGN_CENTER_HORIZONTAL #wx.EXPAND #| ) h_sizer = wx.BoxSizer(wx.HORIZONTAL) self.button_to_start = wx.BitmapButton(self.inner_panel, -1, bitmaps_dict['to_start'], size=(31, 50)) '''Button for moving to start of path.''' self.button_previous_node = wx.BitmapButton( self.inner_panel, -1, bitmaps_dict['previous_node'], size=(31, 50)) '''Button for moving to previous node.''' self.button_center_button = wx.BitmapButton(self.inner_panel, -1, bitmaps_dict['play'], size=(60, 50)) '''Button for playing/pausing playback, and finalizing edited node.''' self.button_next_node = wx.BitmapButton(self.inner_panel, -1, bitmaps_dict['next_node'], size=(31, 50)) '''Button for moving to next node.''' self.button_to_end = wx.BitmapButton(self.inner_panel, -1, bitmaps_dict['to_end'], size=(31, 50)) '''Button for moving to end of path.''' self.Bind(wx.EVT_BUTTON, self.on_button_to_start, source=self.button_to_start) self.Bind(wx.EVT_BUTTON, self.on_button_previous_node, source=self.button_previous_node) self.Bind(wx.EVT_BUTTON, self.on_button_center_button, source=self.button_center_button) self.Bind(wx.EVT_BUTTON, self.on_button_next_node, source=self.button_next_node) self.Bind(wx.EVT_BUTTON, self.on_button_to_end, source=self.button_to_end) button_line = (self.button_to_start, self.button_previous_node, self.button_center_button, self.button_next_node, self.button_to_end) for button in button_line: h_sizer.Add(button, 0) v_sizer.Add(h_sizer, 0) #1, wx.EXPAND) self.scratch_wheel = ScratchWheel(self.inner_panel, self.gui_project, -1, size=(184, 44)) v_sizer.Add(self.scratch_wheel, 0) self.inner_panel.SetSizer(v_sizer) knob_sizer.Layout() h_sizer.Layout() v_sizer.Layout() self.center_button_update_flag = True '''Flag saying whether the center button needs update.''' self.navigation_buttons_update_flag = True '''Flag saying whether the navigation buttons need update.''' self.playing_speed_knob_update_flag = True '''Flag saying whether the playing speed knob needs update.''' self.center_button_needs_update_emitter = \ self.gui_project.emitter_system.make_emitter( inputs=( self.gui_project.playing_toggled_emitter, self.gui_project.active_node_changed_or_modified_emitter, self.gui_project.active_node_finalized_emitter ), outputs=( FlagRaiser(self, 'center_button_update_flag', function=self._update_center_button, delay=0.03), ), name='playback_controls_center_button_needs_update', ) self.navigation_buttons_need_update_emitter = \ self.gui_project.emitter_system.make_emitter( inputs=( self.gui_project.active_node_changed_emitter, self.gui_project.path_contents_changed_emitter ), outputs=( FlagRaiser( self, 'navigation_buttons_update_flag', function=self._update_navigation_buttons, delay=0.03 ), ), name='playback_controls_navigation_buttons_need_update', ) self.gui_project.official_playing_speed_modified_emitter.add_output( FlagRaiser(self.playing_speed_knob, 'recalculation_flag', self.playing_speed_knob._recalculate, delay=0.03))
def __init__(self, *args, **kwargs): if not kwargs.pop("skip_dialog_init", False): wx.Dialog.__init__(self, *args, **kwargs) self.SetBackgroundColour(wx_tools.get_background_color())
def __init__(self, parent, frame): assert isinstance(frame, garlicsim_wx.Frame) self.frame = frame self.gui_project = frame.gui_project assert isinstance(self.gui_project, garlicsim_wx.GuiProject) wx.Panel.__init__(self, parent, -1) self.SetBackgroundColour(wx_tools.get_background_color()) tooltip_text = ('Set the clock buffer that will be crunched ' 'automatically from the active node.') self.SetToolTipString(tooltip_text) self.frozen = 0 self.freezer = Freezer(self) self.main_h_sizer = wx.BoxSizer(wx.HORIZONTAL) self.SetSizer(self.main_h_sizer) self.check_box = wx.CheckBox(self, -1, 'Autocrunch: ') self.check_box.SetToolTipString(tooltip_text) self.main_h_sizer.Add(self.check_box, 0, wx.EXPAND | wx.ALIGN_CENTER_VERTICAL | wx.RIGHT, border=10) self.spin_ctrl = wx.SpinCtrl(self, -1, max=10000000) self.spin_ctrl.SetToolTipString(tooltip_text) self.main_h_sizer.Add(self.spin_ctrl, 0, wx.ALIGN_CENTER_VERTICAL | wx.ALIGN_RIGHT) self.check_box.SetValue(bool(self.gui_project.default_buffer)) self.spin_ctrl.Enable(bool(self.gui_project.default_buffer)) self.spin_ctrl.SetValue( self.gui_project.default_buffer or \ self.gui_project._default_buffer_before_cancellation or \ 0 ) ### Setting up event handling and emitter connections: ################ # # self.gui_project.default_buffer_modified_emitter.add_output( self.update_check_box) self.Bind(wx.EVT_CHECKBOX, self.on_check_box, source=self.check_box) self.Bind(wx.EVT_SPINCTRL, self.on_spin, self.spin_ctrl) self.Bind(wx.EVT_TEXT, self.on_text, self.spin_ctrl) self.gui_project.default_buffer_modified_emitter.add_output( self.update_spin_ctrl)