def init_help_screen(self): """ Initializes the help screen. """ self.help_screen = wx.Panel(parent=self, size=(-1,-1)) self.help_notebook = \ wx.aui.AuiNotebook(parent=self.help_screen, style=wx.aui.AUI_NB_TOP) def give_focus_to_selected_page(event=None): selected_page_number = self.help_notebook.GetSelection() selected_page = self.help_notebook.GetPage(selected_page_number) if self.FindFocus() != selected_page: selected_page.SetFocus() self.help_notebook.Bind(wx.EVT_SET_FOCUS, give_focus_to_selected_page) self.help_notebook.Bind(wx.EVT_CHILD_FOCUS, give_focus_to_selected_page) self.help_images_list=[["Level 1", from_resource_folder("help1.png")], ["Level 2", from_resource_folder("help2.png")], ["Level 3", from_resource_folder("help3.png")], ["Level 4", from_resource_folder("help4.png")]] self.help_pages=[HelpPage(parent=self.help_notebook, bitmap=wx.Bitmap(bitmap_file), caption=caption) \ for [caption, bitmap_file] in self.help_images_list] for page in self.help_pages: try: # avoid TypeError: Required argument 'text' in wxPython > 2.9 self.help_notebook.AddPage(page, text=page.caption) except TypeError: self.help_notebook.AddPage(page, caption=page.caption) self.help_close_button_panel = wx.Panel(parent=self.help_screen) self.help_screen_sizer = wx.BoxSizer(wx.VERTICAL) self.help_screen_sizer.Add(self.help_notebook, 1, wx.EXPAND) self.help_screen_sizer.Add(self.help_close_button_panel, 0, wx.EXPAND) self.help_screen.SetSizer(self.help_screen_sizer) help_close_button_bitmap=wx.Bitmap(from_resource_folder("lets_code.png")) self.help_close_button = \ wx.lib.buttons.GenBitmapButton(self.help_close_button_panel, -1, help_close_button_bitmap) self.help_close_button_sizer = wx.BoxSizer(wx.HORIZONTAL) self.help_close_button_sizer.Add(self.help_close_button, 1, wx.EXPAND | wx.ALL, 5) self.help_close_button_panel.SetSizer(self.help_close_button_sizer) self.Bind(wx.EVT_BUTTON, self.hide_help, self.help_close_button)
def get_image(cls, imagename, color): """ returns wx.Bitmap colored by imagename """ try: return cls.__images[(imagename, color)] except KeyError: try: img = wx.Bitmap(from_resource_folder(imagename+".png")) except: img = wx.Bitmap(from_resource_folder(Animal.image+".png")) img = cls.__colorize(img, color) cls.__images[(imagename, color)] = img Animal.image_sizes[imagename] = Vector(img.GetSize()) return img
def __init__(self,parent,turtle_queue,*args,**kwargs): wx.Panel.__init__(self,parent,style=wx.SUNKEN_BORDER,*args,**kwargs) self.BACKGROUND_COLOR = wx.Colour(212,208,200) self.TURTLE_IMAGE = wx.Bitmap(from_resource_folder("turtle.png")) self.turtle = Turtle() #bitmap=self.bitmap=wx.EmptyBitmapRGBA(2000,1200,BACKGROUND_COLOR[0],BACKGROUND_COLOR[1],BACKGROUND_COLOR[2],255) # todo: Change to something smarter? self.bitmap = wx.EmptyBitmap(*BITMAP_SIZE) self.Bind(wx.EVT_PAINT, self.on_paint) self.Bind(wx.EVT_SIZE,self.on_size) self.Bind(wx.EVT_IDLE,self.on_idle) self.turtle_queue = turtle_queue self.idle_block = False
def __init__(self,*args,**keywords): wx.Frame.__init__(self,*args,**keywords) self.SetDoubleBuffered(True) self.SetIcon(wx.Icon(from_resource_folder("icon.ico"), wx.BITMAP_TYPE_ICO)) self.init_help_screen() self.turtle_process = turtleprocess.TurtleProcess() self.turtle_process.start() self.turtle_queue = self.turtle_process.turtle_queue self.init_menu_bar() self.init_about_dialog_info() self.splitter = wx.SplitterWindow(self, style=wx.SP_LIVE_UPDATE) self.turtle_widget = turtlewidget.TurtleWidget(self.splitter, self.turtle_queue) self.bottom_sizer_panel = wx.Panel(self.splitter) self.shell = \ shelltoprocess.Shell(self.bottom_sizer_panel, queue_pack=self.turtle_process.queue_pack) self.help_open_button_panel = \ wx.Panel(parent=self.bottom_sizer_panel) help_open_button_bitmap = wx.Bitmap(from_resource_folder("teach_me.png")) self.help_open_button = \ wx.lib.buttons.GenBitmapButton(self.help_open_button_panel, -1, help_open_button_bitmap) self.help_open_button_sizer = \ wx.BoxSizer(wx.VERTICAL) self.help_open_button_sizer.Add(self.help_open_button, 1, wx.EXPAND | wx.ALL, 5) self.help_open_button_panel.SetSizer(self.help_open_button_sizer) self.Bind(wx.EVT_BUTTON, self.show_help, self.help_open_button) self.bottom_sizer = wx.BoxSizer(wx.HORIZONTAL) self.bottom_sizer.Add(self.shell, 1, wx.EXPAND) self.bottom_sizer.Add(self.help_open_button_panel, 0, wx.EXPAND) self.bottom_sizer_panel.SetSizer(self.bottom_sizer) desired_shell_height=210 self.splitter.SplitHorizontally(self.turtle_widget, self.bottom_sizer_panel, -desired_shell_height) self.splitter.SetSashGravity(1) self.sizer=wx.BoxSizer(wx.HORIZONTAL) self.sizer.Add(self.splitter, 1, wx.EXPAND) self.sizer.Add(self.help_screen, 1, wx.EXPAND) self.hide_help() self.SetSizer(self.sizer) self.Centre() self.Maximize() self.Show() self.Layout() self.splitter.SetSashPosition(-desired_shell_height) self.shell.setFocus()