def __init__(self): bmp = wx.Image(app_abs_path("images/splash.png")).ConvertToBitmap() wx.SplashScreen.__init__(self, bmp, wx.SPLASH_CENTRE_ON_SCREEN | wx.SPLASH_NO_TIMEOUT, 5000, None, -1) self.has_app_initialized = False self.min_time_shown = False self.Bind(wx.EVT_CLOSE, self.OnClose) wx.FutureCall(2000, self.check_and_close)
def _ogre_init(self, size, render_system): cfg_path = os.path.join(get_user_app_dir(), 'ogre.cfg') log_path = os.path.join(get_user_app_dir(), 'ogre.log') plugins_path = './plugins.cfg' root = ogre.Root(plugins_path, cfg_path, log_path) self.root = root rm = ogre.ResourceGroupManager.getSingleton() add = rm.addResourceLocation add(app_abs_path('materials'), 'FileSystem', 'General') if not os.path.exists(cfg_path): _continue = root.showConfigDialog() else: _continue = root.restoreConfig() if not _continue: sys.exit('Quit from Config Dialog') root.initialise(False) params = ogre.NameValuePairList() params['externalWindowHandle'] = str(self.GetHandle()) x, y = size r = root.createRenderWindow('pide render', x, y, False, params) r.active = True self.render_window = r rm.initialiseAllResourceGroups()
def _add_menu_item(self, menu, item, name, help="", image=None): menu_item = wx.MenuItem(menu, item, name, help) if image: image = app_abs_path("icons", image + ".png") image = load_image(image, (16, 16)) menu_item.SetBitmap(image) menu.AppendItem(menu_item)
def __init__( self, parent, app_state, id=-1, title="", pos=wx.DefaultPosition, size=wx.DefaultSize, style=wx.DEFAULT_FRAME_STYLE | wx.SUNKEN_BORDER | wx.CLIP_CHILDREN | wx.MAXIMIZE, app=None, ): wx.Frame.__init__(self, parent, id, title, pos, size, style) self.app = app self.app_state = app_state self.documents = {} self.vcontainers = {} #: viewer containers self.mgr = wx.aui.AuiManager() self.mgr.SetManagedWindow(self) self.viewer = None #: 3D viewer panel self.pyshell = None #: python shell window self.log_viewer = None #: Log viewer window self.debug_panel = None #: debug panel contains # log_viewer and pyshell windows self.xpath_container = None #: Xpath container self.build_tree_container = None #: Build Tree container self.config_container = None #: Recipe Configuration container self.menu_bar = None #: application menu self.status_bar = None #: application status bar self.tool_bars = [] #: application tool bars self.tabs_panel = None #: tabs panel self._tab_images = None #: image list for tabs self._tab_image_indices = None #: tab image indices map self._close_sent = False self._cleaning_up = False # start building frame self.SetMinSize(self.MIN_SIZE) favicon = wx.Icon(app_abs_path("images/procodile.ico"), wx.BITMAP_TYPE_ICO, 16, 16) self.SetIcon(favicon) self._create_menus() self._create_statusbar() self._create_toolbar() self._create_panes() self.mgr.Update() self._register_for_events()
def _mixin_setup(self): group = optparse.OptionGroup( self, "Options for conf_dir" ) self.add_option_group(group) group.add_option( '-c', '--config_dir', dest='config_dir', default=app_abs_path('conf/'), help='Pass in an alternative configuration dir. Default: %default' )
def _init_tree_images(self): size = (16,16) images = wx.ImageList(*size) L = lambda x: load_image(app_abs_path('icons', x + '.png'), size) self._image_indices['generator'] = images.Add(L('generator_icon')) self._images_list = images self.widget.SetImageList(images)
def _init_tree_images(self): size = (16, 16) images = wx.ImageList(*size) L = lambda x: load_image(app_abs_path("icons", x + ".png"), size) self._image_indices["root"] = images.Add(L("build_tree")) self._image_indices["generator"] = images.Add(L("generator_icon")) self._image_indices["geom"] = images.Add(L("geom_icon")) self._images_list = images self.SetImageList(images)
def _init_tree_images(self): size = (16,16) images = wx.ImageList(*size) L = lambda x: load_image(app_abs_path('icons', x + '.png'), size) self._image_indices['modification'] = images.Add(L('c_mod')) self._image_indices['add_mod'] = images.Add(L('c_mod_n')) self._image_indices['condition'] = images.Add(L('c_condition')) self._image_indices['action'] = images.Add(L('c_action')) self._images_list = images self.widget.SetImageList(images)
def on_view_navigation(self, event): mode = self.app.toggle_document_navigation(None) self.app.set_document_view(None, "perspective") FLY_MODE = 0 EXAMINE_MODE = 1 if mode == FLY_MODE: shelp = "Change navigation to examine mode" image = "vexamine" else: shelp = "Change navigation to fly mode" image = "vfly" image = app_abs_path("icons", image + ".png") image = load_image(image, (24, 24)) toolbar = event.GetEventObject() toolbar.SetToolNormalBitmap(self.ID_VIEW_NAVIGATION, image) toolbar.SetToolShortHelp(self.ID_VIEW_NAVIGATION, shelp)
def parse_args(self, args=None, values=None): options, args = super(ConfParser, self).parse_args(args, values) self.process_config_dir() logger.setup_file_logger(app_abs_path(self.config["swall"]["log_file"]), self.config["swall"]["log_level"]) return options, args
def _ensure_schema(self): state_schema_fpath = app_abs_path("state.schema") self._cursor.executescript(open(state_schema_fpath).read()) self._conn.commit()
def _create_panes(self): self.pyshell = wx.py.shell.Shell(self, -1, locals=self.app.shell_vars) self.log_viewer = LogViewer(self, -1) log.addHandler(self.log_viewer) style = wx.aui.AUI_NB_DEFAULT_STYLE style &= ~wx.aui.AUI_NB_CLOSE_BUTTON style &= ~wx.aui.AUI_NB_CLOSE_ON_ALL_TABS style &= ~wx.aui.AUI_NB_CLOSE_ON_ACTIVE_TAB self.debug_panel = wx.aui.AuiNotebook(self, style=style) self.debug_panel.AddPage(self.pyshell, "Shell") self.debug_panel.AddPage(self.log_viewer, "Log") self.viewer = viewer.Viewer(self, -1, self, size=(1, 1)) self.viewer.Hide() self.xpath_container = ContainerPanel(self, -1) self.build_tree_container = ContainerPanel(self, -1) self.config_container = ContainerPanel(self, -1) style = fnb.FNB_NODRAG | fnb.FNB_ALLOW_FOREIGN_DND size = (16, 16) L = lambda x: load_image(app_abs_path("icons", x + ".png"), size) tg = self._tab_images = wx.ImageList(*size) ti = self._tab_image_indices = {} ti["running"] = tg.Add(L("doc_running")) ti["paused"] = tg.Add(L("doc_paused")) ti["idle"] = tg.Add(L("doc_idle")) self.tabs_panel = fnb.FlatNotebook(self, self.ID_TAB_PANEL, style=style) self.tabs_panel.SetImageList(tg) self._rmenu = wx.Menu() item = wx.MenuItem(self._rmenu, self.ID_TAB_PROPERTIES, "Properties", "Tab Properties") self._rmenu.AppendItem(item) item = wx.MenuItem(self._rmenu, self.ID_TAB_DELETE, "Close Tab\tCtrl+F4", "Close Tab") self._rmenu.AppendItem(item) self.tabs_panel.SetRightClickMenu(self._rmenu) self.mgr.AddPane( self.tabs_panel, wx.aui.AuiPaneInfo() .Name("tabs") .Caption("Documents") .Top() .CenterPane() .MaximizeButton() .MinSize((320, 240)), ) self.mgr.AddPane( self.xpath_container, wx.aui.AuiPaneInfo() .Name("xpath_container") .Caption("Selection Suggestions") .Right() .MaximizeButton() .MinSize((250, 100)), ) self.mgr.AddPane( self.build_tree_container, wx.aui.AuiPaneInfo() .Name("build_tree_container") .Caption("Build Tree") .Right() .MaximizeButton() .MinSize((250, 100)), ) self.mgr.AddPane( self.config_container, wx.aui.AuiPaneInfo() .Name("config_container") .Caption("Configuration") .Left() .MaximizeButton() .MinSize((250, 200)), ) self.mgr.AddPane( self.debug_panel, wx.aui.AuiPaneInfo().Name("debug").Caption("Debug").Bottom().MaximizeButton().MinSize((150, 200)).Hide(), ) for index, tb in enumerate(self.tool_bars): self.mgr.AddPane( tb, wx.aui.AuiPaneInfo().Name("tb_%s" % index).Caption("ToolBar").ToolbarPane().Top().PaneBorder(False) )
def A(tb, _id, text, img, shelp="", lhelp=""): img = app_abs_path("icons", img + ".png") img = load_image(img, size) tb.AddLabelTool(_id, text, img, shortHelp=shelp, longHelp=lhelp)
def __init__(self, parent, doc): wx.Panel.__init__(self, parent) self.app = doc.app self.recipe = doc.recipe self.root = None self.generators = [] self.sizer = wx.BoxSizer(wx.VERTICAL) self.SetSizer(self.sizer) self.Freeze() self.widget = CT.CustomTreeCtrl(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TR_DEFAULT_STYLE | wx.TR_HIDE_ROOT | \ wx.TR_SINGLE |wx.TR_NO_LINES | wx.TR_NO_BUTTONS) self.widget.SetIndent(-10) self.sizer.Add(self.widget, 1, wx.EXPAND) self._image_list = None self._image_indices = {} self._init_tree_images() w = self.widget self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnItemFocus, w) #: buttons self.button_sizer = wx.BoxSizer(wx.HORIZONTAL) s = (16, 16) L = lambda x: load_image(app_abs_path('icons', x + '.png'), s) st = platebtn.PB_STYLE_DEFAULT pb = platebtn.PlateButton self.add_button = pb(self, wx.ID_ANY, '', L('c_add'), style=st) self.edit_button = pb(self, wx.ID_ANY, '', L('c_edit'), style=st) self.del_button = pb(self, wx.ID_ANY, '', L('c_del'), style=st) self.up_button = pb(self, wx.ID_ANY, '', L('c_up'), style=st) self.down_button = pb(self, wx.ID_ANY, '', L('c_down'), style=st) self.Bind(wx.EVT_BUTTON, self.OnAddButton, self.add_button) self.Bind(wx.EVT_BUTTON, self.OnEditButton, self.edit_button) self.Bind(wx.EVT_BUTTON, self.OnDelButton, self.del_button) self.Bind(wx.EVT_BUTTON, self.OnUpButton, self.up_button) self.Bind(wx.EVT_BUTTON, self.OnDownButton, self.down_button) self.button_sizer.Add(self.add_button, 0, wx.ALIGN_RIGHT) self.button_sizer.Add(self.edit_button, 0, wx.ALIGN_RIGHT) self.button_sizer.Add(self.del_button, 0, wx.ALIGN_RIGHT) self.button_sizer.Add(self.up_button, 0, wx.ALIGN_RIGHT) self.button_sizer.Add(self.down_button, 0, wx.ALIGN_RIGHT) self.button_sizer.Layout() self.sizer.Add(self.button_sizer, 0, wx.ALIGN_RIGHT) self.sizer.Layout() self.Thaw() self.fill()
def __init__(self, parent, doc): wx.Panel.__init__(self, parent) self.doc = doc self.recipe = doc.recipe self.root = None self.add_match_node = None self.mod_no = 0 self.Freeze() self.widget = CT.CustomTreeCtrl(self, wx.ID_ANY, wx.DefaultPosition, wx.DefaultSize, wx.TR_DEFAULT_STYLE | wx.TR_HIDE_ROOT | \ wx.TR_SINGLE | wx.TR_EDIT_LABELS | \ wx.TR_NO_LINES) self._image_list = None self._image_indices = {} self._init_tree_images() w = self.widget self.Bind(wx.EVT_TREE_ITEM_ACTIVATED, self.OnItemFocus, w) # self.Bind(wx.EVT_TREE_KEY_DOWN, self.OnModFocus, w) self.Bind(wx.EVT_TREE_BEGIN_LABEL_EDIT, self.OnLabelEditStart, w) self.Bind(wx.EVT_TREE_END_LABEL_EDIT, self.OnLabelEditEnd, w) self.sizer = wx.BoxSizer(wx.VERTICAL) self.SetSizer(self.sizer) self.sizer.Add(self.widget, 1, wx.EXPAND) #: buttons self.button_sizer = wx.BoxSizer(wx.HORIZONTAL) s = (16, 16) L = lambda x: load_image(app_abs_path('icons', x + '.png'), s) st = platebtn.PB_STYLE_DEFAULT pb = platebtn.PlateButton self.mod_button = pb(self, wx.ID_ANY, '', L('c_mod_n'), style=st) self.condition_button = pb(self, wx.ID_ANY, '', L('c_condition_n'), style=st) self.action_button = pb(self, wx.ID_ANY, '', L('c_action_n'), style=st) self.edit_button = pb(self, wx.ID_ANY, '', L('c_edit'), style=st) self.del_button = pb(self, wx.ID_ANY, '', L('c_del'), style=st) self.up_button = pb(self, wx.ID_ANY, '', L('c_up'), style=st) self.down_button = pb(self, wx.ID_ANY, '', L('c_down'), style=st) self.Bind(wx.EVT_BUTTON, self.OnModButton, self.mod_button) self.Bind(wx.EVT_BUTTON, self.OnConditionButton, self.condition_button) self.Bind(wx.EVT_BUTTON, self.OnActionButton, self.action_button) self.Bind(wx.EVT_BUTTON, self.OnEditButton, self.edit_button) self.Bind(wx.EVT_BUTTON, self.OnDelButton, self.del_button) self.Bind(wx.EVT_BUTTON, self.OnUpButton, self.up_button) self.Bind(wx.EVT_BUTTON, self.OnDownButton, self.down_button) self.button_sizer.Add(self.mod_button, 0, wx.ALIGN_RIGHT) self.button_sizer.Add(self.condition_button, 0, wx.ALIGN_RIGHT) self.button_sizer.Add(self.action_button, 0, wx.ALIGN_RIGHT) self.button_sizer.Add(self.edit_button, 0, wx.ALIGN_RIGHT) self.button_sizer.Add(self.del_button, 0, wx.ALIGN_RIGHT) self.button_sizer.Add(self.up_button, 0, wx.ALIGN_RIGHT) self.button_sizer.Add(self.down_button, 0, wx.ALIGN_RIGHT) self.button_sizer.Layout() self.sizer.Add(self.button_sizer, 0, wx.ALIGN_RIGHT) self.sizer.Layout() self.Thaw() self.fill()