def __init__(self, *args, **kwargs): """ Constructor. """ super(OBDLoadingPanel, self).__init__(*args, **kwargs) # Background image image = wx.Image(BACKGROUND_FILENAME) width, height = wx.GetDisplaySize() image = image.Scale(width, height, wx.IMAGE_QUALITY_HIGH) self.bitmap = wx.BitmapFromImage(image) self.Bind(wx.EVT_PAINT, self.OnPaint) # Logo bitmap = wx.Bitmap(LOGO_FILENAME) width, height = bitmap.GetSize() image = wx.ImageFromBitmap(bitmap) image = image.Scale(width/6, height/6, wx.IMAGE_QUALITY_HIGH) bitmap = wx.BitmapFromImage(image) control = wx.StaticBitmap(self, wx.ID_ANY, bitmap) control.SetPosition((10, 10)) # Create an accelerator table cid = wx.NewId() self.Bind(wx.EVT_MENU, self.onCtrlC, id=cid) self.accel_tbl = wx.AcceleratorTable([ (wx.ACCEL_CTRL, ord('C'), cid), ]) self.SetAcceleratorTable(self.accel_tbl) # Connection self.c = None # Sensors list self.sensors = [] # Port self.port = None
def initWindow(self): # 2 if self.fullScreen: self.size = self.app.size = wx.GetDisplaySize() if sys.platform == 'darwin': # correct on mac? because of the nmenu and status bar self.framesize = self.size[0], self.size[1] + 25 # 22 #+15 elif sys.platform == 'win32': # windows etc... self.framesize = self.size[0] + 8, self.size[ 1] + 46 # 54 only menu else: # i guess it is linux self.framesize = self.size[0], self.size[ 1] + 27 # 27 with menu, 54 with status bar on linux ## print self.size , self.app.size, self.framesize self.frame = self.frameClass(self.app, None, -1, self.caption, self.pos, self.framesize) # init if sys.platform == 'darwin': self.canvas = glcanvas.GLCanvas(self.frame, -1, self.pos, self.frame.GetClientSize()) else: self.canvas = glcanvas.GLCanvas( self.frame, -1, self.pos, self.size) #, name=self.caption) self.canvas.Bind(wx.EVT_PAINT, self.OnPaint) self.canvas.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground) # dummy def OnCloseWindow(evt): self.t.Stop() self.frame.Destroy() self.frame.Bind(wx.EVT_CLOSE, OnCloseWindow) self.glsize = self.canvas.GetSize( ) # passed to glOrtho in engine initialisation self.frame.doFrame(self.canvas) if self.fullScreen: self.frame.ShowFullScreen(1) self.SetTopWindow(self.frame) self.frame.Show()
def __init__(self, parent, title, config, iconfile="logo.ico", tabbed=None): """ initialize window and feed in links to presenter and config. :param parent: GUniDec Presenter -> self.pres :param title: Window title (string) :param config: UniDecConfig object ->self.config :return: None """ wx.Frame.__init__(self, None, title=title) # Set presenter and config self.pres = parent self.config = config self.title = title self.controls = None self.plots = [] self.plotnames = [] self.version = self.pres.eng.version if iconfile is None: iconfile = "logo.ico" # Set Icon File try: if os.path.isfile(iconfile): favicon = wx.Icon(iconfile, wx.BITMAP_TYPE_ANY) wx.Frame.SetIcon(self, favicon) self.icon_path = os.path.abspath(iconfile) else: self.icon_path = None except Exception as e: print(e) self.icon_path = None # Get display size and intelligently reshape self.system = platform.system() self.displaysize = wx.GetDisplaySize() pub.subscribe(self.on_motion, 'newxy')
def __init__(self, parent, title): wx.Frame.__init__(self, parent, title=title, size=wx.GetDisplaySize()) MainPanel = wx.Panel(self, size=self.GetSize()) MainPanel.SetBackgroundColour(wx.Colour(0, 0, 255)) panel_KPH = wx.Panel(self, size=(500, 500), pos=(0, 0)) panel_RPM = wx.Panel(self, size=(500, 500), pos=(500, 0)) panel_Fuel = wx.Panel(self, size=(250, 250), pos=(1000, 0)) panel_Temp = wx.Panel(self, size=(250, 250), pos=(1000, 250)) #bind on esc key self.Bind(wx.EVT_CHAR_HOOK, self.onKey) # Eyes burning <remove later> panel_KPH.SetBackgroundColour(wx.Colour(255, 33, 33)) panel_RPM.SetBackgroundColour(wx.Colour(33, 255, 33)) box = wx.BoxSizer(wx.VERTICAL) box.Add(panel_KPH, 0) box.Add(panel_RPM, 1) MainPanel.SetSizer(box) #GridSizer #gs = wx.GridSizer(2,1,5,5) #gs.Add(self.speedmeter = speedmeter.SpeedMeter(panel)) #gs.Add(self.speedmeter1 = speedmeter.SpeedMeter(panel1)) ''' # Start self.btn_start_stop = wx.Button(MainPanel, label="Start") self.btn_start_stop.Bind(wx.EVT_BUTTON, self.OnStartStop) ''' # Add speedmeter self.Speed = meter_Speed.SpeedMeter(panel_KPH, panel_KPH.GetSize()) self.RPM = meter_RPM.SpeedMeter(panel_RPM, panel_RPM.GetSize()) self.Fuel = meter_Fuel.SpeedMeter(panel_Fuel, panel_Fuel.GetSize()) self.Temp = meter_Temp.SpeedMeter(panel_Temp, panel_Temp.GetSize()) self.ShowFullScreen(True)
def SetPopupPositionByInt(self, pos): """ Sets the :class:`ToasterBox` position on screen, at one of the screen corners. :param `pos`: an integer specifying the screen corner, namely: ============= ======================================== Corner Number Position ============= ======================================== 0 Top left screen corner 1 Top right screen corner 2 Bottom left screen corner 3 Bottom right screen corner ============= ======================================== """ w, h = wx.GetDisplaySize() self._bottomright = wx.Point(w, h) # top left if pos == 0: popupposition = wx.Point(0, 0) # top right elif pos == 1: popupposition = wx.Point(w - self._popupsize[0], 0) # bottom left elif pos == 2: popupposition = wx.Point(0, h - self._popupsize[1]) # bottom right elif pos == 3: popupposition = wx.Point(self._bottomright.x - self._popupsize[0], self._bottomright.y - self._popupsize[1]) self._bottomright = wx.Point(popupposition.x + self._popupsize[0], popupposition.y + self._popupsize[1]) self._popupposition = popupposition
def run(self): # Remove the renderer from the current render window. self.old_rw.remove_renderer(self.ren) # Creates renderwindow tha should be used ONLY for # visualization in full screen full_rw = tvtk.RenderWindow(stereo_capable_window=True, full_screen=True) # add the current visualization full_rw.add_renderer(self.ren) # Under OS X there is no support for creating a full screen # window so we set the size of the window here. if sys.platform == 'darwin': full_rw.size = tuple(wx.GetDisplaySize()) # provides a simple interactor style = tvtk.InteractorStyleTrackballCamera() self.iren = tvtk.RenderWindowInteractor(render_window=full_rw, interactor_style=style) # Gets parameters for stereo visualization if self.old_rw.stereo_render: full_rw.trait_set(stereo_type=self.old_rw.stereo_type, stereo_render=True) # Starts the interactor self.iren.initialize() self.iren.render() self.iren.start() # Once the full screen window is quit this releases the # renderer before it is destroyed, and return it to the main # renderwindow. full_rw.remove_renderer(self.ren) self.old_rw.add_renderer(self.ren) self.old_rw.render() self.iren.disable()
def __init__(self, parent=None, title="Info"): self.font = wx.Font(18, wx.DEFAULT, wx.NORMAL, wx.NORMAL, False, 'Arial') self.font_field = wx.Font(24, wx.DEFAULT, wx.NORMAL, wx.FONTWEIGHT_BOLD, False, 'Arial') self.font_button = wx.Font(12, wx.DEFAULT, wx.NORMAL, wx.NORMAL, False, 'Arial') self.font_title = wx.Font(36, wx.DEFAULT, wx.NORMAL, wx.NORMAL, False, 'Lucida Handwriting') self.width, self.height = wx.GetDisplaySize() #self.height -= 100 self.sizer_w = 10 self.sizer_h = 10 super(Msgbox, self).__init__(parent, title=title, size=(self.width, self.height), style=wx.DEFAULT_FRAME_STYLE | wx.RESIZE_BORDER) isz = (16, 16) ico = wx.Icon('./data/imgs/others/logo.png', wx.BITMAP_TYPE_PNG, isz[0], isz[1]) self.SetIcon(ico) self.fname = '' self.lname = '' self.name = '' self.id = '' self.num = '' self.gender = '' self.isCli = False self.isPat = False self.init_ui() self.Centre() self.Show() self.Maximize(True)
def __init__(self, parent, title): self.init_text() self.width, self.height = wx.GetDisplaySize() ratio = self.height / 600.0 self.player_width = 640 * ratio self.player_height = 360 * ratio self.height -= 100 # self.width = 1100 # self.height = self.player_height * 1.5 + 45 self.sizer_w = 5 self.sizer_h = 5 super(Instrcution_win, self).__init__(parent, title=title, size=(self.width, self.height)) isz = (16, 16) ico = wx.Icon('./data/imgs/others/logo.png', wx.BITMAP_TYPE_PNG, isz[0], isz[1]) self.SetIcon(ico) self.init_ui() self.Show()
def notify(frame, msg="", title=u"消息"): if os.name == "posix" and sys.platform != "darwin": # linux 系统 pynotify.Notification(title, msg).show() return import ToasterBox as TB sw, sh = wx.GetDisplaySize() width, height = 210, 50 px = sw - 230 py = sh - 100 tb = TB.ToasterBox(frame) tb.SetPopupText(msg) tb.SetPopupSize((width, height)) tb.SetPopupPosition((px, py)) tb.Play() frame.SetFocus()
def OnNotify(self, evt): """Handle notification events @param evt: L{ed_event.NotificationEvent} """ e_val = evt.GetValue() if evt.GetId() == ID_UPDATE_CHECK and \ isinstance(e_val, tuple) and e_val[0]: mdlg = wx.MessageDialog(self.GetActiveWindow(), _("An updated version of Editra is available\n" "Would you like to download Editra %s now?") %\ e_val[1], _("Update Available"), wx.YES_NO|wx.YES_DEFAULT|wx.CENTER|wx.ICON_INFORMATION) if mdlg.ShowModal() == wx.ID_YES: dl_dlg = updater.DownloadDialog(None, wx.ID_ANY, _("Downloading Update")) dp_sz = wx.GetDisplaySize() dl_dlg.SetPosition( ((dp_sz[0] - (dl_dlg.GetSize()[0] + 5)), 25)) dl_dlg.Show() mdlg.Destroy() else: evt.Skip()
def CenterOnScreen(self, direction=wx.BOTH): """ Centres the :class:`ToasterBox` on screen. :param `direction`: specifies the direction for the centering. May be ``wx.HORIZONTAL``, ``wx.VERTICAL`` or ``wx.BOTH``. :see: :meth:`~ToasterBox.CenterOnParent`. """ screenSize = wx.GetDisplaySize() toast_width, toast_height = self._popupsize width, height = screenSize.GetWidth(), screenSize.GetHeight() if direction == wx.VERTICAL: pos = wx.Point(0, (height / 2) - (toast_height / 2)) elif direction == wx.HORIZONTAL: pos = wx.Point((width / 2) - (toast_width / 2), 0) else: pos = wx.Point((width / 2) - (toast_width / 2), (height / 2) - (toast_height / 2)) tb.SetPopupPosition(pos)
def Preview(self, bmp): """Show the print preview @param bmp: wx.Bitmap """ printout = self.CreatePrintout(bmp) printout2 = self.CreatePrintout(bmp) preview = wx.PrintPreview(printout, printout2, self.print_data) preview.SetZoom(100) if preview.IsOk(): pre_frame = wx.PreviewFrame(preview, self.parent, "Print Preview") # The default size of the preview frame # sometimes needs some help. dsize = wx.GetDisplaySize() width = self.parent.GetSize()[0] height = dsize.GetHeight() - 100 pre_frame.SetInitialSize((width, height)) pre_frame.Initialize() pre_frame.Show() else: # Error wx.MessageBox("Failed to create print preview", "Print Error", style=wx.ICON_ERROR | wx.OK)
def __init__(self, parent, MainScreen, domain, port, name, fc=[], *args, **kwargs): super(ServerRTC, self).__init__(parent, *args, **kwargs) print "Inside ServerRTC" self.MainScreen = MainScreen self.TreeItemId = None self.Hide() self.GetCaret().Hide() self.SetSize(wx.GetDisplaySize()) self.SetEditable(False) self.domain = domain self.name = name self.topic_name = '' self.port = port self.fc = fc self.connected = False
def Display(self): pos = self.ctrl.ClientToScreen( (0,0) ) dSize = wx.GetDisplaySize() selfSize = self.GetSize() tcSize = self.ctrl.GetSize() pos.x -= (selfSize.width - tcSize.width) / 2 if pos.x + selfSize.width > dSize.width: pos.x = dSize.width - selfSize.width if pos.x < 0: pos.x = 0 pos.y += tcSize.height if pos.y + selfSize.height > dSize.height: pos.y = dSize.height - selfSize.height if pos.y < 0: pos.y = 0 self.Move(pos) self.ctrl.FormatContent() self.ShowModal()
def __init__(self, parent, id=wx.ID_ANY, size=wx.DefaultSize, style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER | wx.MAXIMIZE_BOX | wx.MINIMIZE_BOX, dir=None, fps=25.0, leftToRight=True, pixelsPerSec=None, photoFolder=DefaultPhotoFolder): if size == wx.DefaultSize: displayWidth, displayHeight = wx.GetDisplaySize() width = int(displayWidth * 0.9) height = 780 size = wx.Size(width, height) super(FinishStripDialog, self).__init__(parent, id, size=size, style=style, title=_('Finish Strip')) self.panel = FinishStripPanel(self, fps=fps, photoFolder=photoFolder) self.okButton = wx.Button(self, wx.ID_OK) self.okButton.SetDefault() vs = wx.BoxSizer(wx.VERTICAL) vs.Add(self.panel, flag=wx.EXPAND) vs.Add(self.okButton, flag=wx.ALIGN_CENTRE | wx.ALL, border=4) self.SetSizer(vs) self.panel.SetLeftToRight(leftToRight) if pixelsPerSec is not None: self.panel.SetPixelsPerSec(pixelsPerSec)
def __init__( self, parent, pageClass, closeCallback=None, title=_("Change Properties"), ID=wx.ID_ANY, size=wx.DefaultSize, pos=wx.DefaultPosition, style=wx.DEFAULT_DIALOG_STYLE | wx.RESIZE_BORDER | wx.MINIMIZE_BOX | wx.MAXIMIZE_BOX, ): if size == wx.DefaultSize: size = tuple(int(v * 0.5) for v in wx.GetDisplaySize()) super(PageDialog, self).__init__(parent, ID, title=title, size=size, pos=pos, style=style) # Set the upper left icon. icon = wx.Icon( os.path.join(Utils.getImageFolder(), 'CrossMgr16x16.ico'), wx.BITMAP_TYPE_ICO) self.SetIcon(icon) sizer = wx.BoxSizer(wx.VERTICAL) self.SetSizer(sizer) self.page = pageClass(self) sizer.Add(self.page, 1, flag=wx.ALL | wx.EXPAND, border=5) self.closeCallback = closeCallback self.Bind(wx.EVT_CLOSE, self.onCloseWindow) self.Bind(wx.EVT_LEAVE_WINDOW, self.onLeaveWindow)
def __init__(self, WD=None, name='Main Frame', dmodel=None): try: version = pmag.get_version() except: version = "" title = "MagIC GUI version: %s" % version if sys.platform in ['win32', 'win64']: title += " Powered by Enthought Canopy" wx.Frame.__init__(self, None, wx.ID_ANY, title, name=name) # self.grid_frame = None self.panel = wx.Panel(self, size=wx.GetDisplaySize(), name='main panel') print '-I- Fetching working directory' self.WD = os.path.realpath(WD) or os.getcwd() print '-I- Initializing magic data object' if dmodel is None: dmodel = validate_upload.get_data_model() self.data_model = dmodel self.er_magic = builder.ErMagicBuilder(self.WD, self.data_model) self.edited = False self.validation_mode = False # initialize magic data object # attempt to read magic_measurements.txt, and all er_* and pmag_* files print '-I- Read in any available data from working directory' self.er_magic.get_all_magic_info() # POSSIBLY RELOCATE THIS EVENTUALLY: print '-I- Initializing headers' self.er_magic.init_default_headers() self.er_magic.init_actual_headers() # print '-I- Initializing interface' self.InitUI()
def saveSettings(self, settings_file = "mxwst-settings.cfg"): try: config = ConfigParser.ConfigParser() config.read(settings_file) if not config.has_section('last_used_settings'): config.add_section('last_used_settings') if not config.has_section('settings'): config.add_section('settings') sr_width, sr_height = wx.GetDisplaySize() config.set('last_used_settings', 'mea_host_url', self.parent.main_panel.RESED_panel.mea_url.GetValue()) config.set('last_used_settings', 'mea_service', self.parent.main_panel.RESED_panel.mea_srvc.GetValue()) config.set('last_used_settings', 'app_width', str( sr_width/decimal.Decimal(self.parent.GetSize()[0]+0.000001)) ) config.set('last_used_settings', 'app_height', str( sr_height/decimal.Decimal(self.parent.GetSize()[1]+0.000001)) ) config.set('last_used_settings', 'app_position_x', str( sr_width/decimal.Decimal(self.parent.GetPosition()[0]+0.000001)) ) config.set('last_used_settings', 'app_position_y', str( sr_height/decimal.Decimal(self.parent.GetPosition()[1]+0.000001)) ) config.set('last_used_settings', 'split_position', str( decimal.Decimal(self.parent.GetSize()[1])/decimal.Decimal(self.parent.main_panel.sptr1.GetSashPosition()+0.000001) ) ) config.set('last_used_settings', 'last_opened_files', self.parent.main_panel.XMLED_panel.getOpenedFiles()) config.set('settings', 'request_timeout', self.parent.main_panel.RESED_panel.reqPr.prop_value_timeout.GetValue()) config.set('settings', 'username', self.parent.main_panel.RESED_panel.reqPr.prop_value_username.GetValue()) config.set('settings', 'content-type', self.parent.main_panel.RESED_panel.reqPr.prop_value_content_type.GetValue()) config.set('settings', 'soapaction', self.parent.main_panel.RESED_panel.reqPr.prop_value_soapaction.GetValue()) try: pmsji = SimpleCryption() config.set('settings', 'password', pmsji.encode("@==L/;',?##--|?S.&?%##%$|/*@!+_~~zM??m0O0$\\l1L11sWLOO0", self.parent.main_panel.RESED_panel.reqPr.prop_value_password.GetValue()) ) except Exception: aplgr.log('Error encrypting password') with open(settings_file, 'wb') as configfile: config.write(configfile) except Exception as e: aplgr.log('Error saving settings.\n'+str(e))
def OnButton(self, evt): self.pop = CalendarPopup(self) txtValue = self.GetValue() dmy = txtValue.split('.') didSet = False if len(dmy) == 3: d = int(dmy[0]) m = int(dmy[1]) - 1 y = int(dmy[2]) if d > 0 and d < 31: if m >= 0 and m < 12: if y > 1000: self.pop.cal.SetDate(DateTimeFromDMY(d, m, y)) didSet = True if not didSet: self.pop.cal.SetDate(DateTime_Today()) pos = self.ClientToScreen((0, 0)) display_size = wx.GetDisplaySize() popup_size = self.pop.GetSize() control_size = self.GetSize() pos.x -= (popup_size.x - control_size.x) / 2 if pos.x + popup_size.x > display_size.x: pos.x = display_size.x - popup_size.x if pos.x < 0: pos.x = 0 pos.y += control_size.height if pos.y + popup_size.y > display_size.y: pos.y = display_size.y - popup_size.y if pos.y < 0: pos.y = 0 self.pop.MoveXY(pos.x, pos.y) wx.calendar.EVT_CALENDAR_DAY(self, self.pop.cal.GetId(), self.OnCalSelected) self.pop.Popup()
def edit_button_click(self, event=None): try: component = self.editList.get_selected() except: return if not component: return path = self.window.objectPath if not path: path = self.window.GetTitle() obj = component app = wx.GetApp() objectpath = ''.join( [self.editList.get_text(), ' component of ', path]) if wx.GetKeyState(wx.WXK_CONTROL) or not app.show_object_frame(obj): frame = self.pug(obj=obj, parent=None, objectpath=objectpath, show=False) self_rect = self.control.GetTopLevelParent().GetScreenRect() frame_rect = frame.GetScreenRect() display_size = wx.GetDisplaySize() if self_rect.Right + frame_rect.Width < display_size[0]: x = self_rect.Right elif self_rect.Left - frame_rect.Width > 0: x = self_rect.Left - frame_rect.Width else: x = 0 if self_rect.Top + frame_rect.Height < display_size[1]: y = self_rect.Top elif frame_rect.Height < display_size[1]: y = display_size[1] - frame_rect.Height else: y = 0 frame.SetPosition((x, y)) frame.Show()
def SetPopupPositionByInt(self, pos): """ Sets the ToasterBox position on screen, at one of the screen corners. """ w, h = wx.GetDisplaySize() self._bottomright = wx.Point(w, h) # top left if pos == 0: popupposition = wx.Point(0, 0) # top right elif pos == 1: popupposition = wx.Point(w - self._popupsize[0], 0) # bottom left elif pos == 2: popupposition = wx.Point(0, h - self._popupsize[1]) # bottom right elif pos == 3: popupposition = wx.Point(self._bottomright.x - self._popupsize[0], self._bottomright.y - self._popupsize[1]) self._bottomright = wx.Point(popupposition.x + self._popupsize[0], popupposition.y + self._popupsize[1]) self._dialogtop = popupposition
def __init__(self): # initialize superclass wx.Frame.__init__(self, None, title='GNU Dynamic (FORTH)') # set window icon self.SetIcon(wx.ArtProvider.GetIcon(wx.ART_INFORMATION)) # show window self.Show() # add control elements # W,H = self.GetSize() # main window size # SW0,SH0 = wx.GetDisplaySizeMM() # in mm SW1, SH1 = wx.GetDisplaySize() # in pixels self.SetSize((SW1 / 2, SH1 / 2)) # main window size self.font = wx.Font( SH1 / 32, # console font wx.FONTFAMILY_MODERN, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_BOLD) self.sizer = wx.BoxSizer(wx.VERTICAL) self.SetSizer(self.sizer) ## console self.console = wx.TextCtrl(self, style=wx.TE_MULTILINE) self.console.SetFont(self.font) self.console.SetValue('console') self.console.SetBackgroundColour('#000000') self.console.SetForegroundColour('#00AA00') self.sizer.Add(self.console, 3, wx.EXPAND) #,wx.EXPAND|wx.ALL) ## commands entry field self.command = wx.TextCtrl(self, style=wx.TE_MULTILINE) self.command.SetFont(self.font) self.command.SetValue('command') self.command.SetBackgroundColour('#000022') self.command.SetForegroundColour('#FFFF00') self.sizer.Add(self.command, 1, wx.EXPAND) #,wx.EXPAND|wx.ALL) # allot space self.sizer.Fit(self)
def Position(self, ptOrigin, size): size = wx.Point(*size) ptOrigin = wx.Point(*ptOrigin) sizeScreen = wx.GetDisplaySize() sizeSelf = self.Size # is there enough space to put the popup below the window (where we put it # by default)? y = ptOrigin.y + size.y if ( y + sizeSelf.y > sizeScreen.y ): # check if there is enough space above if ( ptOrigin.y > sizeSelf.y ): # do position the control above the window y -= size.y + sizeSelf.y; #else: not enough space below nor above, leave below # now check left/right too x = ptOrigin.x; if ( wx.GetApp().GetLayoutDirection() == wx.Layout_RightToLeft ): # shift the window to the left instead of the right. x -= size.x; x -= sizeSelf.x; # also shift it by window width. else: x += size.x; if ( x + sizeSelf.x > sizeScreen.x ): # check if there is enough space to the left if ( ptOrigin.x > sizeSelf.x ): # do position the control to the left x -= size.x + sizeSelf.x; #else: not enough space there neither, leave in default position #BM: do we need this flag below? it isn't defined self.Move((x, y))#, wx.SIZE_NO_ADJUSTMENTS);
def show_popup(self): '''Show the text notification popup.''' text = self.__msgtext.GetValue() if text: # Text is set, show dialog. Status of text notification. self.__textnotif = 'show' font = self.__data.get_sys('msg_font') colors = self.__data.get_sys('popup_colors') icon = os.path.join(self.__dir, self.__data.get_sys('icon_close')) popup = Popup(parent=self, style=self.__bdist, text=text, font=font, colors=colors, icon=icon) popw, poph = popup.get_size() dispw, disph = wx.GetDisplaySize() offx = (dispw - popw) / 2 offy = (disph - poph) / 2 popup.Position(ptOrigin=(0, 0), size=(offx, offy)) popup.Popup() else: # No text, no Popup, set __textnotif 'close'. self.__textnotif = 'close'
def __init__(self): """ Constructor. """ wx.Frame.__init__(self, None, wx.ID_ANY, "OBD-Pi") image = wx.Image(BACKGROUND_FILENAME) width, height = wx.GetDisplaySize() image = image.Scale(width, height, wx.IMAGE_QUALITY_HIGH) self.bitmap = wx.BitmapFromImage(image) self.Bind(wx.EVT_PAINT, self.OnPaint) self.panelLoading = OBDLoadingPanel(self) self.sizer = wx.BoxSizer(wx.VERTICAL) self.sizer.Add(self.panelLoading, 1, wx.EXPAND) self.SetSizer(self.sizer) self.panelLoading.showLoadingScreen() self.panelLoading.SetFocus() panel = wx.Panel(self) # close button closeBtn = wx.Button(panel, label="Close") closeBtn.Bind(wx.EVT_BUTTON, self.onClose)
def OnInit(self): self.version = psychopy.__version__ self.SetAppName('PsychoPy2') #show splash screen splash = PsychoSplashScreen() if splash: splash.Show() #LONG IMPORTS - these need to be imported after splash screen starts (they're slow) #but then that they end up being local so keep track in self splash.status.SetLabel(" Loading PsychoPy2..." + uidRootFlag) from psychopy.monitors import MonitorCenter from psychopy.app import coder, builder, wxIDs, connections, urls #set default paths and prefs self.prefs = preferences.Preferences() #from preferences.py if self.prefs.app['debugMode']: log.console.setLevel(log.DEBUG) self.keys = self.prefs.keys self.prefs.pageCurrent = 0 # track last-viewed page of prefs, to return there self.IDs = wxIDs self.urls = urls.urls self.quitting = False self.updater = None #create an updater when it's needed #setup links for URLs #on a mac, don't exit when the last frame is deleted, just show a menu if sys.platform == 'darwin': self.menuFrame = MenuFrame(parent=None, app=self) #get preferred view(s) from prefs and previous view if self.prefs.app['defaultView'] == 'last': mainFrame = self.prefs.appData['lastFrame'] else: # configobjValidate should take care of this situation (?), but doesn't: if self.prefs.app['defaultView'] in [ 'last', 'coder', 'builder', 'both' ]: mainFrame = self.prefs.app['defaultView'] else: self.prefs.app['defaultView'] = 'both' mainFrame = 'both' #fetch prev files if that's the preference if self.prefs.coder['reloadPrevFiles']: scripts = self.prefs.appData['coder']['prevFiles'] else: scripts = [] if self.prefs.builder['reloadPrevExp'] and ( 'prevFiles' in self.prefs.appData['builder'].keys()): exps = self.prefs.appData['builder']['prevFiles'] else: exps = [] #then override the prev files by command options and passed files if len(sys.argv) > 1: if sys.argv[1] == __name__: args = sys.argv[ 2:] # program was excecuted as "python.exe PsychoPyIDE.py %1' else: args = sys.argv[ 1:] # program was excecuted as "PsychoPyIDE.py %1' #choose which frame to start with if args[0] in ['builder', '--builder', '-b']: mainFrame = 'builder' args = args[1:] #can remove that argument elif args[0] in ['coder', '--coder', '-c']: mainFrame = 'coder' args = args[1:] #can remove that argument #did we get .py or .psyexp files? elif args[0][-7:] == '.psyexp': mainFrame = 'builder' exps = [args[0]] elif args[0][-3:] == '.py': mainFrame = 'coder' scripts = [args[0]] else: args = [] self.dpi = int(wx.GetDisplaySize()[0] / float(wx.GetDisplaySizeMM()[0]) * 25.4) if not (50 < self.dpi < 120): self.dpi = 80 #dpi was unreasonable, make one up #create both frame for coder/builder as necess self.coder = None self.builderFrames = [] self.copiedRoutine = None self.allFrames = [ ] #these are ordered and the order is updated with self.onNewTopWindow if mainFrame in ['both', 'coder']: self.showCoder(fileList=scripts) if mainFrame in ['both', 'builder']: self.showBuilder(fileList=exps) #send anonymous info to www.psychopy.org/usage.php #please don't disable this - it's important for PsychoPy's development if self.prefs.connections['allowUsageStats']: statsThread = threading.Thread( target=connections.sendUsageStats, args=(self.prefs.connections['proxy'], )) statsThread.start() if self.prefs.connections['checkForUpdates']: self.updater = connections.Updater( app=self, proxy=self.prefs.connections['proxy']) self.updater.suggestUpdate( confirmationDlg=False) #check for updates (silently) else: self.updater = False """This is in wx demo. Probably useful one day. #--------------------------------------------- def ShowTip(self): config = GetConfig() showTipText = config.Read("tips") if showTipText: showTip, index = eval(showTipText) else: showTip, index = (1, 0) if showTip: tp = wx.CreateFileTipProvider(opj("data/tips.txt"), index) ##tp = MyTP(0) showTip = wx.ShowTip(self, tp) index = tp.GetCurrentTip() config.Write("tips", str( (showTip, index) )) config.Flush()""" return True
splashImage = wx.Bitmap("images\\splash.png", wx.BITMAP_TYPE_PNG) else: splashImage = wx.Bitmap("images/splash.png", wx.BITMAP_TYPE_PNG) splash = wx.SplashScreen(splashImage, wx.SPLASH_CENTRE_ON_SCREEN | wx.SPLASH_NO_TIMEOUT, 10000, None, style=wx.FRAME_NO_TASKBAR) wx.Yield() # Start PyMOL # Depending on the computer, the windows may have sizes and positions that are slightly off, so when # the user resizes/repositions them, their settings get saved and loaded by default the next time # this program is run # Import PyMOL with the saved window settings screenW = wx.GetDisplaySize()[0] screenH = wx.GetDisplaySize()[1] # These defaults get the sizes mostly right pymolw = screenW - 370 pymolh = screenH - 340 pymolx = 370 pymoly = 0 try: # Read the saved offsets and modify the coordinates/sizes as needed # Offsets should be saved instead of absolute sizes so we can attempt to scale the windows # if the screen resolution changes (i.e. for projectors and the like) if (platform.system() == "Windows"): f = open(homedir + "\\InteractiveROSETTA\\seqwindow.cfg", "r") else: f = open(homedir + "/.InteractiveROSETTA/seqwindow.cfg", "r") for aline in f:
import cv2 import numpy as np from pynput.mouse import Button, Controller import wx mouse = Controller() app = wx.App(False) (sx, sy) = wx.GetDisplaySize() (camx, camy) = (320, 240) lowerBound = np.array([33, 80, 40]) upperBound = np.array([102, 255, 255]) cam = cv2.VideoCapture(0) #cam.set(3,camx) #cam.set(4,camy) kernelOpen = np.ones((5, 5)) kernelClose = np.ones((20, 20)) pinchFlag = 0 #font = cv2.cv.InitFont(cv2.cv.CV_FONT_HERSHEY_SIMPLEX, 2, 0.5, 0, 3, 1) while True: ret, img = cam.read() #img = cv2.resize(img,(340, 220)) #convert BGR to HSV imgHSV = cv2.cvtColor(img, cv2.COLOR_BGR2HSV) #create mask mask = cv2.inRange(imgHSV, lowerBound, upperBound)
def _move_y_where_room(self, start_y, cell_height): height = _PREFERRED_POPUP_SIZE[1] max_vertical = wx.GetDisplaySize()[1] if max_vertical - start_y - cell_height < height: return start_y - height return start_y + cell_height
def onInit(self, showSplash=True, testMode=False): """ :Parameters: testMode: bool If set to True then startup wizard won't appear and stdout/stderr won't be redirected to the Coder """ self.version = psychopy.__version__ self.SetAppName('PsychoPy2') # import localization after wx: from psychopy.app import localization # needed by splash screen self.localization = localization self.locale = localization.wxlocale self.locale.AddCatalog(self.GetAppName()) # set default paths and prefs self.prefs = psychopy.prefs if self.prefs.app['debugMode']: logging.console.setLevel(logging.DEBUG) # indicates whether we're running for testing purposes self.testMode = testMode self.osf_session = None if showSplash: # show splash screen splashFile = os.path.join( self.prefs.paths['resources'], 'psychopySplash.png') splashBitmap = wx.Image(name=splashFile).ConvertToBitmap() splash = AS.AdvancedSplash(None, bitmap=splashBitmap, timeout=3000, style=AS.AS_TIMEOUT | wx.FRAME_SHAPED, shadowcolour=wx.RED) # transparency? splash.SetTextPosition((10, 240)) splash.SetText(_translate(" Loading libraries...")) else: splash = None # SLOW IMPORTS - these need to be imported after splash screen starts # but then that they end up being local so keep track in self if splash: splash.SetText(_translate(" Loading PsychoPy2...")) from psychopy.compatibility import checkCompatibility # import coder and builder here but only use them later from psychopy.app import coder, builder, dialogs, urls self.keys = self.prefs.keys self.prefs.pageCurrent = 0 # track last-viewed page, can return there self.IDs = IDStore() self.urls = urls.urls self.quitting = False # check compatibility with last run version (before opening windows) self.firstRun = False if '--firstrun' in sys.argv: del sys.argv[sys.argv.index('--firstrun')] self.firstRun = True if 'lastVersion' not in self.prefs.appData: # must be before 1.74.00 last = self.prefs.appData['lastVersion'] = '1.73.04' self.firstRun = True else: last = self.prefs.appData['lastVersion'] if self.firstRun and not self.testMode: self.firstrunWizard() # setup links for URLs # on a mac, don't exit when the last frame is deleted, just show menu if sys.platform == 'darwin': self.menuFrame = MenuFrame(parent=None, app=self) # get preferred view(s) from prefs and previous view if self.prefs.app['defaultView'] == 'last': mainFrame = self.prefs.appData['lastFrame'] else: # configobjValidate should take care of this situation allowed = ['last', 'coder', 'builder', 'both'] if self.prefs.app['defaultView'] in allowed: mainFrame = self.prefs.app['defaultView'] else: self.prefs.app['defaultView'] = 'both' mainFrame = 'both' # fetch prev files if that's the preference if self.prefs.coder['reloadPrevFiles']: scripts = self.prefs.appData['coder']['prevFiles'] else: scripts = [] appKeys = list(self.prefs.appData['builder'].keys()) if self.prefs.builder['reloadPrevExp'] and ('prevFiles' in appKeys): exps = self.prefs.appData['builder']['prevFiles'] else: exps = [] # then override the prev files by command options and passed files if len(sys.argv) > 1: if sys.argv[1] == __name__: # program was executed as "python.exe PsychoPyIDE.py %1' args = sys.argv[2:] else: # program was executed as "PsychoPyIDE.py %1' args = sys.argv[1:] # choose which frame to start with if args[0] in ['builder', '--builder', '-b']: mainFrame = 'builder' args = args[1:] # can remove that argument elif args[0] in ['coder', '--coder', '-c']: mainFrame = 'coder' args = args[1:] # can remove that argument # did we get .py or .psyexp files? elif args[0][-7:] == '.psyexp': mainFrame = 'builder' exps = [args[0]] elif args[0][-3:] == '.py': mainFrame = 'coder' scripts = [args[0]] else: args = [] self.dpi = int(wx.GetDisplaySize()[0] / float(wx.GetDisplaySizeMM()[0]) * 25.4) if not (50 < self.dpi < 120): self.dpi = 80 # dpi was unreasonable, make one up if sys.platform == 'win32': # wx.SYS_DEFAULT_GUI_FONT is default GUI font in Win32 self._mainFont = wx.SystemSettings.GetFont(wx.SYS_DEFAULT_GUI_FONT) else: self._mainFont = wx.SystemSettings.GetFont(wx.SYS_ANSI_FIXED_FONT) self._codeFont = wx.SystemSettings.GetFont(wx.SYS_ANSI_FIXED_FONT) self._codeFont.SetFaceName(self.prefs.coder['codeFont']) # removed Aug 2017: on newer versions of wx (at least on mac) # this looks too big # if hasattr(self._mainFont, 'Larger'): # # Font.Larger is available since wyPython version 2.9.1 # # PsychoPy still supports 2.8 (see ensureMinimal above) # self._mainFont = self._mainFont.Larger() # self._codeFont.SetPointSize( # self._mainFont.GetPointSize()) # unify font size # create both frame for coder/builder as necess if splash: splash.SetText(_translate(" Creating frames...")) self.coder = None self.copiedRoutine = None self.copiedCompon = None self._allFrames = [] # ordered; order updated with self.onNewTopWindow if mainFrame in ['both', 'coder']: self.showCoder(fileList=scripts) if mainFrame in ['both', 'builder']: self.showBuilder(fileList=exps) # send anonymous info to www.psychopy.org/usage.php # please don't disable this, it's important for PsychoPy's development self._latestAvailableVersion = None self.updater = None prefsConn = self.prefs.connections if prefsConn['checkForUpdates'] or prefsConn['allowUsageStats']: connectThread = threading.Thread( target=connections.makeConnections, args=(self,)) connectThread.start() # query github in the background to populate a local cache about # what versions are available for download: from psychopy.tools import versionchooser as vc versionsThread = threading.Thread(target=vc._remoteVersions, args=(True,)) versionsThread.start() ok, msg = checkCompatibility(last, self.version, self.prefs, fix=True) # tell the user what has changed if not ok and not self.firstRun and not self.testMode: title = _translate("Compatibility information") dlg = dialogs.MessageDialog(parent=None, message=msg, type='Info', title=title) dlg.ShowModal() if self.prefs.app['showStartupTips'] and not self.testMode: tipFile = os.path.join( self.prefs.paths['resources'], _translate("tips.txt")) tipIndex = self.prefs.appData['tipIndex'] tp = wx.CreateFileTipProvider(tipFile, tipIndex) showTip = wx.ShowTip(None, tp) self.prefs.appData['tipIndex'] = tp.GetCurrentTip() self.prefs.saveAppData() self.prefs.app['showStartupTips'] = showTip self.prefs.saveUserPrefs() if self.prefs.connections['checkForUpdates']: self.Bind(wx.EVT_IDLE, self.checkUpdates) else: self.Bind(wx.EVT_IDLE, self.onIdle) # doing this once subsequently enables the app to open & switch among # wx-windows on some platforms (Mac 10.9.4) with wx-3.0: if wx.version() >= '3.0' and sys.platform == 'darwin': _Showgui_Hack() # returns ~immediately, no display # focus stays in never-land, so bring back to the app: if mainFrame in ['both', 'builder']: self.showBuilder() else: self.showCoder() return True