Пример #1
0
    def __init__(self,
                 value=0,
                 min_=None,
                 max_=None,
                 listener=None,
                 *args,
                 **kw):
        super().__init__(*args, **kw)
        self.value = value
        self.min = min_
        self.max = max_
        self.listener = listener

        self.left_btn = NormalButton(parent=self, label='◀', size=(30, 30))
        self.display = NormalText(parent=self, label=str(self.value))
        self.right_btn = NormalButton(parent=self, label='▶', size=(30, 30))

        self.timer = Timer()

        if self.min is not None and self.value <= self.min:
            self.left_btn.Disable()

        if self.max is not None and self.value >= self.max:
            self.right_btn.Disable()

        self.layout()
        self.connect()
Пример #2
0
    def __init__(self, parent):
        BaseWindowPanel.__init__(self,
                                 parent,
                                 bg_color=Colour.BLACK,
                                 fg_color=Colour.WHITE)

        self._caption_label = StaticText(self,
                                         pos=(70, 5),
                                         size=(20, 0),
                                         label=u"This month, we spent")
        self._caption_label.SetFont(
            Font(13, FONTFAMILY_DEFAULT, FONTSTYLE_NORMAL, FONTWEIGHT_NORMAL))

        self._display = LEDNumberCtrl(self,
                                      pos=(0, 30),
                                      size=(320, 90),
                                      style=LED_ALIGN_RIGHT)
        self._display.SetValue("0.00")

        self._date_display = LEDNumberCtrl(self,
                                           pos=(110, 150),
                                           size=(210, 40),
                                           style=LED_ALIGN_RIGHT)
        self._date_display.SetValue("--.--.--")

        self._clock_display = LEDNumberCtrl(self,
                                            pos=(110, 190),
                                            size=(210, 50),
                                            style=LED_ALIGN_RIGHT)
        self._clock_display.SetValue("--.--.--")

        self.open_button = Button(self,
                                  -1,
                                  "Add",
                                  pos=(10, 125),
                                  size=(70, 35))
        self.open_button.SetBackgroundColour(Colour.DARK_GREEN)
        self.open_button.SetForegroundColour(Colour.WHITE)

        self.list_button = Button(self,
                                  -1,
                                  "List",
                                  pos=(10, 160),
                                  size=(70, 35))
        self.list_button.SetBackgroundColour(get_colour(0x333333))
        self.list_button.SetForegroundColour(Colour.WHITE)

        self.close_button = Button(self,
                                   -1,
                                   "Close",
                                   pos=(10, 195),
                                   size=(70, 35))
        self.close_button.SetBackgroundColour(Colour.DARK_RED)
        self.close_button.SetForegroundColour(Colour.WHITE)

        self._timer = Timer(self)
        self._timer.Start(100)
        self.Bind(EVT_TIMER, self.on_clock_update, self._timer)
Пример #3
0
    def __init__(self, main_window, *args, **kw):
        super().__init__(*args, **kw)
        self.timer = Timer(self)

        self.main_window = main_window

        self.time_display = WatchText(self, label=TIMER_LABEL)
        self.start_btn = NormalButton(self, label=START_LABEL)
        self.pause_btn = NormalButton(self, label=PAUSE_LABEL)
        self.reset_btn = NormalButton(self, label=STOP_LABEL)

        self.maneger = TimeManeger(self.main_window, self)
        self.layout()
        self.Bind(EVT_TIMER, self.update_watch)
Пример #4
0
    def __init__(self, parent: Window, wxID: int, title: str):
        """

        Args:
            parent:     parent window
            wxID:         wx ID of this frame
            title:      Title to display
        """
        super().__init__(parent, wxID, title, DefaultPosition,
                         Size(FrameWidth, FrameHeight))

        self.logger: Logger = getLogger(__name__)
        # iconFileName: str    = resource_filename(IMAGE_RESOURCES_PACKAGE, 'pyut.ico')
        # icon:         Icon   = Icon(iconFileName, BITMAP_TYPE_ICO)
        #
        # self.SetIcon(icon)
        if sysPlatform != PyutConstants.THE_GREAT_MAC_PLATFORM:

            fileName: str = PyutUtils.getResourcePath(
                packageName=IMAGE_RESOURCES_PACKAGE, fileName='pyut.ico')
            icon: Icon = Icon(fileName, BITMAP_TYPE_ICO)
            self.SetIcon(icon)

        self.Center(BOTH)

        longTextStr: str = PyutUtils.retrieveResourceText(
            ResourceTextType.KUDOS_TEXT_TYPE)
        self._textToShow: List[str] = longTextStr.split('\n')
        # Animation panel
        self._panel: Panel = Panel(self,
                                   ID_ANY,
                                   size=(FrameWidth, FrameHeight))

        # Picture and text
        # bmp = Bitmap("img" + os.sep + "pyut.bmp", BITMAP_TYPE_BMP)
        # fileName = resource_filename(IMAGE_RESOURCES_PACKAGE, 'pyut.bmp')
        fileName: str = PyutUtils.getResourcePath(IMAGE_RESOURCES_PACKAGE,
                                                  'pyut.png')
        # bmp = Bitmap(fileName, BITMAP_TYPE_PNG)

        self._picture: StaticBitmap = StaticBitmap(
            self, ID_ANY, ImgPyut.embeddedImage.GetBitmap())
        summaryText: str = "2020 The PyUt team and Humberto Sanchez II.\nPublished under the GNU General Public License"
        self._label: StaticText = StaticText(self,
                                             ID_ANY,
                                             summaryText,
                                             style=CAPTION)

        # Main sizer
        self.SetAutoLayout(True)
        sizer = BoxSizer(VERTICAL)
        sizer.Add(self._picture, 0, ALL | ALIGN_CENTER, 5)
        sizer.Add(self._panel, 1, ALL | ALIGN_CENTER, 5)
        sizer.Add(self._label, 0, ALL | ALIGN_CENTER, 5)

        btnOk: Button = Button(self, ID_OK, "&Ok")
        sizer.Add(btnOk, 0, ALL | ALIGN_CENTER, 5)
        self.SetSizer(sizer)
        sizer.Fit(self)

        self._textPosition = 0.0  # Current position

        self._timer: Timer = Timer(self)
        self.Bind(EVT_TIMER, self._onTimer, self._timer)

        self.Bind(EVT_BUTTON, self._onOk, btnOk)
        self._panel.Bind(EVT_PAINT, self.OnRefreshPanel)
        self.Bind(EVT_CLOSE, self._onOk)
Пример #5
0
    def startMonitor(self):

        self._timer: Timer = Timer(self)
        self.Bind(EVT_TIMER, self._onTimer, self._timer)
        self._timer.Start(DlgDebugDiagramFrame.DEBUG_TIMER_UPDATE_MSECS)
    def __init__(self,
                 WD=None,
                 write_to_log_file=True,
                 inp_file=None,
                 delay_time=3,
                 data_model=3.0,
                 test_mode_on=True):
        global usr_configs_read, inp_dir, pkg_dir, data_dir, CURRENT_VERSION
        # catch user interruption signal (ctrl+c) so app can still close properly
        # not working right now
        # signal.signal(signal.SIGINT, self.sigint_catcher)
        # if write_to_log_file: start_logger()
        self.title = "Demag GUI Autoupdate | %s" % (
            CURRENT_VERSION.strip("pmagpy-"))
        if WD is None:
            self.WD = os.getcwd()
        else:
            self.WD = os.path.realpath(os.path.expanduser(WD))
        uncached, num_cached_files = uncache_site_files(self.WD)
        # set attribute to be used by read_inp() to warn the user once and only
        # once if there are commented lines in inp file
        self.warn_comments_in_inpfile = False
        if uncached:
            print("-I- Unpacking {} site-level MagIC files previously"
                  " cached".format(num_cached_files))
        WD_short = shortpath(self.WD)
        if not os.path.isdir(self.WD):
            print(f"-E- Working directory {WD_short} does not exist.")
        print(f"-I- Working directory set to {WD_short}")
        # self.delete_magic_files(self.WD)
        self.data_model = data_model
        self.delay_time = delay_time

        if inp_file is None:
            temp_inp_pick = wx.Frame()
            if usr_configs_read:
                inp_file_name = self.pick_inp(temp_inp_pick, inp_dir)
                if inp_file_name is None:
                    ls_inp_dir = list(
                        os.path.join(inp_dir, s) for s in os.listdir(inp_dir))
                    inp_file_name = max(ls_inp_dir, key=os.path.getmtime)
                    print("-W- No .inp file selected. Reading most recently"
                          " opened file: %s" %
                          (os.path.basename(inp_file_name)))
            else:
                inp_file_name = self.pick_inp(temp_inp_pick, self.WD)
            temp_inp_pick.Destroy()
        elif not os.path.isfile(os.path.realpath(inp_file)):
            inp_file = os.path.realpath(inp_file)
            if os.path.isfile(os.path.join(self.WD, inp_file)):
                inp_file_name = os.path.join(self.WD, inp_file)
            elif usr_configs_read:
                if os.path.isfile(
                        os.path.join(inp_dir, os.path.basename(inp_file))):
                    inp_file_name = os.path.join(inp_dir,
                                                 os.path.basename(inp_file))
            else:
                print(f"-E- Could not find .inp file {inp_file}")
                return
        else:
            inp_file_name = inp_file

        self.inp_file = inp_file_name
        magic_files = {}
        self.read_inp(self.WD, self.inp_file, magic_files, self.data_model)
        self.combine_magic_files(self.WD, magic_files, self.data_model)
        # self.on_new_inp()
        # self.update_loop(force_update=True)

        try:
            super(Demag_GUIAU, self).__init__(
                WD=WD,
                # overwrite this for log testing purposes;
                # should override the superclass logging methods
                # for this eventually
                write_to_log_file=False,
                data_model=data_model,
                test_mode_on=test_mode_on)
        except ValueError:
            raise ValueError("-E- Data model you entered is not a number")
        # make changes to the demag_gui parent frame
        # add buttons for triggering autoupdate functions
        self.au_add_buttons()
        # set AU icon
        self.au_set_icon()
        # add read .inp option to menubar
        self.menubar = super().GetMenuBar()
        menu_file = self.menubar.GetMenu(0)
        m_read_inp = menu_file.Insert(1, -1, "Read .inp file\tCtrl-I", "")
        self.Bind(wx.EVT_MENU, self.on_menu_pick_read_inp, m_read_inp)
        self.menubar.Refresh()
        # make statusbar
        self.statusbar = self.CreateStatusBar()

        # find .inp file
        # if inp_file is None:
        #     if usr_configs_read:
        #         inp_file_name = self.pick_inp(self,inp_dir)
        #     else:
        #         inp_file_name = self.pick_inp(self,self.WD)
        # elif not os.path.isfile(os.path.realpath(inp_file)):
        #     inp_file = os.path.realpath(inp_file)
        #     if os.path.isfile(os.path.join(self.WD, inp_file)):
        #         inp_file_name = os.path.join(self.WD, inp_file)
        #     elif usr_configs_read:
        #         if os.path.isfile(os.path.join(inp_dir, os.path.basename(inp_file))):
        #             inp_file_name = os.path.join(inp_dir, os.path.basename(inp_file))
        #     else:
        #         print(f"-E- Could not find .inp file {inp_file}")
        #         return
        # else:
        #     inp_file_name = inp_file

        # self.inp_file = inp_file_name
        # magic_files = {}
        # self.read_inp(self.WD, self.inp_file, magic_files, self.data_model)
        # self.combine_magic_files(self.WD, magic_files, self.data_model)
        self.on_new_inp()
        self.update_loop(force_update=True)
        self.set_statusbar()

        self.timer = Timer(self, ID_ANY)
        self.timer.Start(self.delay_time * 1000)
        self.Bind(EVT_TIMER, self.on_timer)
        self.Bind(wx.EVT_CLOSE, self.OnClose)
        # disable test mode to enable dialogs once GUI has started up
        super().set_test_mode(False)