示例#1
0
def main():
    def on_closing():
        if ctrl.isNoteModified():
            if messagebox.askyesno("Quit",
                                   "Do you want to quit?\nNote is modified."):
                root.destroy()
        else:
            root.destroy()

    root = Tk()
    root.protocol("WM_DELETE_WINDOW", on_closing)
    scriptpath = os.path.realpath(__file__)
    imagepath = scriptpath.replace("main.py", "images/notes.png")
    icon = PhotoImage(file=imagepath)
    root.call('wm', 'iconphoto', root._w, icon)
    root.title("Notes")
    root.rowconfigure(0, weight=1)
    root.columnconfigure(0, weight=1)
    f = MainFrame(root)
    f.grid(row=0, column=0, sticky='nswe', padx=3, pady=3)

    ctrl = Controller(f)
    ctrl.startWork()

    root.option_add('*Dialog.msg.font', 'Helvetica 11')

    root.mainloop()

    ctrl.endWork()
示例#2
0
    def __init__(self, controller_factory, track_mode=False, debug=False, mark_using_pixels=False, zoom=1):
        logger.debug("Creating Application View")
        self.controller = controller_factory.create_controller(self)

        self.wx_app = wx.App(False)
        logger.debug("App built")
        self.debug = debug
        self.mark_using_pixels = mark_using_pixels

        self.mainframe = MainFrame(self.controller, track_mode=track_mode)
        self.image_view_manager = ImageViewManager(self.mainframe, zoom)
        self.menu = Menu(self.mainframe, self.controller)
        self.keybind_manager = KeybindManager(self.mainframe, self.controller)

        self.loading_dialog = WaitingGaugeDialog(self.mainframe,
                                                 "Image loading...")

        # Handle user clicking on the window's "x" button
        self.mainframe.Bind(wx.EVT_CLOSE, self._on_close_window)

        self.accept_source_dialog = None
        self.reject_source_dialog = None
        self.certificate_dialog = None
        self.retry_downloads_dialog = None

        # TODO refactor
        self.register_xy_changed_event_handler(self.controller.on_reposition_source)
        logger.debug("Done.")
示例#3
0
class UISpyApp(wx.App):
    def OnInit(self):
        self.main = MainFrame()
        self.main.Center()
        self.main.Show()
        self.SetTopWindow(self.main)
        return True
示例#4
0
def testFont():
    root = Tk()
    root.title("Finally Pycharm working with tkinter")
    available = families()
    print(len(available))
    print("availabe: ", available)
    f = MainFrame(root)
    f.grid(row=0, column=0)

    root.mainloop()
示例#5
0
def main(args=None):
#   init_translator()                       # i18n
#   tray = SysTray()                        # Трей

    app = QtGui.QApplication(sys.argv)      # Приложение

    frame = MainFrame(args)                 # Инициализируем
    frame.show()                            # Отображаем

    res = app.exec_()                       # Цикл
    return res
示例#6
0
def main():
    app = QApplication(sys.argv)

    splash = QSplashScreen()
    splash.setPixmap(QPixmap('ui/image.jpg'))
    splash.show()

    window = MainFrame()
    window.show()
    splash.finish(window)

    sys.exit(app.exec_())
示例#7
0
    def __init__(self):
        super(MainWindow, self).__init__()
        self.setFixedSize(MainWindow.WIDTH, MainWindow.HEIGHT)

        self.mainTitle = Title('Distributed Real-time Risk', 36)
        self.subTitle = Title(' ' * 36 + 'Team 23', 20)

        layout = QGridLayout(self)
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(0)

        assert LeftPanel.OFFSET_Y == MainFrame.OFFSET_Y
        assert LeftPanel.HEIGHT == MainFrame.HEIGHT
        assert LeftPanel.OFFSET_Y + LeftPanel.HEIGHT == BottomPanel.OFFSET_Y
        assert BottomPanel.OFFSET_Y + BottomPanel.HEIGHT == MainWindow.HEIGHT
        layout.setRowStretch(0, LeftPanel.OFFSET_Y)
        layout.setRowStretch(1, LeftPanel.HEIGHT)
        layout.setRowStretch(2, BottomPanel.HEIGHT)

        assert LeftPanel.WIDTH + MainFrame.WIDTH == MainWindow.WIDTH
        layout.setColumnStretch(0, LeftPanel.WIDTH)
        layout.setColumnStretch(1, MainFrame.WIDTH)

        self.leftPanel = LeftPanel()
        self.bottomPanel = BottomPanel()
        self.mainFrame = MainFrame()
        layout.addWidget(self.leftPanel, 1, 0)
        layout.addWidget(self.bottomPanel, 2, 0, 1, -1)
        layout.addWidget(self.mainFrame, 1, 1)

        self.bottomPanel.gameHallControl.backButtonClicked.connect(
            self._onBackButtonClicked)
        self.bottomPanel.gameHallControl.createButtonClicked.connect(
            self._onCreateButtonClicked)
        self.bottomPanel.gameHallControl.joinButtonClicked.connect(
            self._onJoinButtonClicked)
        self.bottomPanel.gameRoomControl.backButtonClicked.connect(
            self._onBackButtonClicked)
        self.bottomPanel.gameRoomControl.startButtonClicked.connect(
            self._onStartButtonClicked)
        self.leftPanel.gameHallPanel.mapList.mapSelected.connect(
            self._onMapSelected)
        self.leftPanel.gameHallPanel.gameList.gameSelected.connect(
            self._onGameSelected)

        self.selectedMap = None
        self.selectedGameLoader = None
        self.selectedGame = None

        self.state = MainWindow.STATE_NONE
        self.initialAnimationStarted = False
        QMetaObject.invokeMethod(self, '_startAnimation', Qt.QueuedConnection)
示例#8
0
文件: appview.py 项目: OSSOS/MOP
    def __init__(self, controller_factory, track_mode=False, debug=False, mark_using_pixels=False, zoom=1):
        logger.debug("Creating Application View")
        self.controller = controller_factory.create_controller(self)

        self.wx_app = wx.App(False)
        logger.debug("App built")
        self.debug = debug
        self.mark_using_pixels = mark_using_pixels

        self.mainframe = MainFrame(self.controller, track_mode=track_mode)
        self.image_view_manager = ImageViewManager(self.mainframe, zoom)
        self.menu = Menu(self.mainframe, self.controller)
        self.keybind_manager = KeybindManager(self.mainframe, self.controller)

        self.loading_dialog = WaitingGaugeDialog(self.mainframe,
                                                 "Image loading...")

        # Handle user clicking on the window's "x" button
        self.mainframe.Bind(wx.EVT_CLOSE, self._on_close_window)

        self.accept_source_dialog = None
        self.reject_source_dialog = None
        self.certificate_dialog = None
        self.retry_downloads_dialog = None

        # TODO refactor
        self.register_xy_changed_event_handler(self.controller.on_reposition_source)
        logger.debug("Done.")
示例#9
0
def run(capture=False):
    """ Run the application.
        capture: True to capture stderr and stdout in special window
    """
    wxapp = wx.PySimpleApp(capture)
    colourdb.updateColourDB()
    wxapp.SetAssertMode(wx.PYAPP_ASSERT_EXCEPTION) #wx.PYAPP_ASSERT_DIALOG
    MainFrame().Show(True)
    wxapp.MainLoop()
示例#10
0
class Magnificient(wx.App):
    def OnInit(self):
        self.InitUI()
        return True

    def InitUI(self):
        self.frame = MainFrame(None)
        self.frame.Show()
        self.frame.logFrame.Show(True)
示例#11
0
def do_wxadmin():
    try:
        import wx
        from mainframe import MainFrame
    except:
        print_status('Can not import wxpython.')
        raise

    app = wx.App()
    MainFrame(None, -1, 'Kay WxAdmin')
    app.MainLoop()
示例#12
0
文件: main.py 项目: shaurz/devo
    def Startup(self, args):
        from dialogs import dialogs
        try:
            import async_wx
            from app_instance import AppListener, get_app_instance
            from fileutil import get_user_config_dir, mkpath
            from log_file import get_log_file

            async_wx.set_wx_scheduler()

            config_dir = get_user_config_dir("devo")
            try:
                mkpath(config_dir)
            except OSError as e:
                message = "Failed to create Devo configuration directory:\n\n" + str(e)
                dialogs.error(None, message, "Initialization Error")
                return False

            if not args.new_instance:
                instance = get_app_instance("devo")
                if instance:
                    try:
                        if instance.call("process_args", args.raw_args, os.getcwd()):
                            return False
                    except Exception:
                        pass

                self.listener = AppListener("devo", DevoAppHandler(self))

            if hasattr(sys, "frozen"):
                log_filename = os.path.join(config_dir, "errors.log")
                self.log_file = get_log_file(log_filename)
                sys.stdout, self.stdout = self.log_file, sys.stdout
                sys.stderr, self.stderr = self.log_file, sys.stderr

            from mainframe import MainFrame
            self.mainframe = MainFrame.__new__(MainFrame, args)
            self.mainframe.__init__(args)
            self.SetTopWindow(self.mainframe)

            self.Bind(wx.EVT_END_SESSION, self.OnEndSession)

            return True

        except Exception:
            message = "Devo failed to initialize due to the following error:\n\n" + traceback.format_exc()
            if self.mainframe:
                try:
                    self.mainframe.Destroy()
                except Exception:
                    pass
            dialogs.error(None, message, "Initialization Error")
            return False
示例#13
0
    def setUp(self):
        root = Tk()
        mainframe = MainFrame(root)
        mainframe.root.update()
        mainframe.root.withdraw()

        self.manager = mainframe.manager
        self.board = self.manager.model.curr_state
        self.board.to_move = BLACK
        squares = self.board.squares
        # make initial 11-15 move for Black
        squares[18] = FREE
        squares[24] = BLACK | MAN
示例#14
0
class MoPresc(wx.App):
    """
    The Main wx App Object
    """
    def __init__(self, parent=None):
        self.main_frame = None
        wx.App.__init__(self, parent)

    def OnInit(self):
        """ Initializes the App """
        self.main_frame = MainFrame(None)
        self.main_frame.Show()
        return True
示例#15
0
 def OnInit(self):
     self.main = MainFrame()
     self.main.Center()
     self.main.Show()
     self.SetTopWindow(self.main)
     return True
示例#16
0
    #     elif item_2 < item:
    #         summ_list.append(item_2)
    #         item_2 = list2.pop(0)
    #         if list2.__len__() != 0:
    #             item_2 = list2.pop(0)
    #         else:
    #               print(item, item_2)
    #             print(list)
    #             print(list2)
    #             merge(item, list)
    #             break

    multiprocessing.freeze_support()
    pos, size, style = GetConfigurations()
    app = wx.App()
    frm = MainFrame(None, title=APP_NAME, size=size, pos=pos, style=style)
    # frm.Show()
    app.MainLoop()

# import wx
#
# class MyFrame(wx.Frame):
#     def __init__(self, parent, ID, title):
#         wx.Frame.__init__(self, parent, ID, title)
#
#         self.timer = wx.Timer(self, 1)
#         self.count = 0
#
#         self.Bind(wx.EVT_TIMER, self.OnTimer, self.timer)
#
#         panel = wx.Panel(self, -1)
示例#17
0
    def __init__(self, root):

        self.topframe = TopFrame(root, self)
        self.mainframe = MainFrame(root, self)
        self.uris = {}
示例#18
0
class Gui:
    """ 
    Main GUI object that handles communication between the visual
    layer and the Crazyflie.
    It consists of a Top frame, which is the menu and a main frame,
    which contains all the visual logs to the Crazyflie.
    """
    def __init__(self, root):

        self.topframe = TopFrame(root, self)
        self.mainframe = MainFrame(root, self)
        self.uris = {}

    def add_uri(self, uri):
        """ 
        Tries to add a URI to the listbox and make a new LogFrame
        object out of it. Raises a warning message is URI already exists
        """
        try:
            self.mainframe.canvas.delete('warning')
        finally:
            if uri not in self.uris:
                self.topframe.uribox.insert('end', uri)
                row, column = Calculate.row_and_col(self.uris)
                self.uris[uri] = LogFrame(self.mainframe.canvas, row, column,
                                          uri)
                self.mainframe.update_canvas_scroll()
            else:
                self.mainframe.warning_msg('You already have that URI added')

    def del_uris(self, uris):
        """ Deletes selected uris and repositions the remaining ones """
        for uri in uris:
            if uri in self.uris:
                self.uris[uri].delete()
                self.uris.pop(uri)

        for i, uri in enumerate(self.uris):
            row, column = Calculate.new_placements(i)
            self.uris[uri].delete()
            self.uris[uri] = LogFrame(self.mainframe.canvas, row, column, uri)

    def clear_uris(self):
        for uri in self.uris:
            self.uris[uri].delete()
        self.uris = {}

    def run_test(self, test):
        """ Runs the chosen test on all Crazyflies, with their own threads """
        if self.uris:
            for uri in self.uris:
                try:
                    self.uris[uri].reset_motors()
                    self.uris[uri].reset_battery()
                except AttributeError:
                    pass
                finally:
                    Thread(target=self.start, args=(uri, test)).start()

    def start(self, uri, test):
        cflib.crtp.init_drivers(enable_debug_driver=False)

        cf = HealthTest(uri, self, test)
        try:
            cf.open_link()
            cf.run_test()
        finally:
            cf.close_link()

    def warning_msg(self, msg):
        self.mainframe.warning_msg(msg)

    # Callbacks from Crazyflie

    def connecting(self, uri):
        self.uris[uri].update_status_text('Connecting...')

    def running_test(self, uri):
        self.uris[uri].update_status_text('Running Test...')

    def connected(self, uri):
        self.uris[uri].clear_status_text()
        self.uris[uri].show_motors()
        self.uris[uri].show_battery()

    def connection_failed(self, uri):
        self.uris[uri].update_status_text('Connection Failed', fg='red')

    def connection_lost(self, uri):
        self.uris[uri].update_status_text('Connection Lost', fg='red')

    def disconnected(self, uri):
        self.uris[uri].update_status_text('Disconnected', fg='red')

    def cb_logs(self, uri, motor_values, battery):
        """
        Callback with all the logs from the Crazyflie 
        This gets sent to the LogFrame object that can represent
        the values visually
        """
        if not self.uris[uri].test_is_done:
            motor_text = Calculate.motor_text(motor_values)
            motor_fill = Calculate.motor_fill(motor_values)
            b_text, b_fill = Calculate.battery(battery)

            self.uris[uri].update_motors(motor_fill, motor_text)
            self.uris[uri].update_battery(b_text, b_fill)

    def hover_test_done(self, uri, means):
        self.uris[uri].test_is_done = True
        time.sleep(0.1)
        results, colors = Calculate.is_mean_ok(means)
        self.uris[uri].update_motor_status(results, colors)

    def propeller_test_done(self, motorlog, uri):
        self.uris[uri].test_is_done = True
        time.sleep(0.1)
        results, colors = Calculate.propeller_result(motorlog)
        self.uris[uri].update_motor_status(results, colors)
示例#19
0
    x, y = event.x, event.y
    print('{}, {}'.format(x, y))


root = tk.Tk()
root.geometry('800x480')
root.wm_title("AMX Automation Labs")
root["bg"] = "#29b18a"

print(root['bg'])

io.setmode(io.BOARD)

pins = [3, 7, 11, 13]

print("[-]Getting pins down.... Ahh, This Power Outage!!")
#for i in range(4):
#    io.setup(pins[i],io.OUT)
#    io.output(pins[i],1)
print("[+]Taken down all the pins!")
print("Ready!")

root.attributes("-fullscreen", True)

root.bind('<Motion>', motion)

mainframe = MainFrame(root, 800, 480)
mainframe.pack(side="left", fill="y")

root.mainloop()
示例#20
0
import wx
from mainframe import MainFrame
import multiprocessing
import configparser
CP = configparser.ConfigParser()
CP.read('bitmaps/userPositionConfig.ini')
pos = int(CP['POSITION']['positionX']), int(CP['POSITION']['positionY'])
if __name__ == '__main__':

    multiprocessing.freeze_support()
    app = wx.App()
    size = wx.Size(945, 685)
    pos = wx.Point(pos)
    frame = MainFrame(None,
                      title='Graduate work',
                      size=size,
                      pos=pos,
                      style=wx.DEFAULT_FRAME_STYLE | wx.STAY_ON_TOP)
    frame.Show()
    app.MainLoop()
示例#21
0

    #LogRecord.instance().logger.info(u"进入主函数")  
    #将字体文件名传给addApplicationFont,得到字体的Id
    #fontId = QFontDatabase.addApplicationFont("./simhei.ttf")
    #将字体Id传给applicationFontFamilies,得到一个QStringList,其中的第一个元素为新添加字体的family
    #msyh = QFontDatabase.applicationFontFamilies(fontId)[0]
    #font = QFont(msyh,10)
    #将此字体设为QApplication的默认字体
    #app.setFont(font)


    #加载QSS样式表
    #qss= QFile("clouds.qss")
    #qss.open(QFile.ReadOnly)
    #app.setStyleSheet(QString(qss.readAll()))
    #qss.close()
    
    #关闭屏保
    #os.system("xset dpms 0 0 0")
    #os.system("xset s 0 0")
    #os.system("setenforce 0")
       
    window = MainFrame()
    window.show()
    #window.repaint()
    #window.setPosition()
    
    #time.sleep(5)
    app.exec_()
示例#22
0
 def OnInit(self):
     self.mainFrame = MainFrame(None, size = (wx.DisplaySize()[0]-50,wx.DisplaySize()[1]),
                                title = "Flash download v1.0 2018-06-30")
     self.SetTopWindow(self.mainFrame)
     return True
示例#23
0
class ApplicationView(object):
    """
    Provides the view's external interface.
    """

    def __init__(self, controller_factory, track_mode=False, debug=False, mark_using_pixels=False, zoom=1):
        logger.debug("Creating Application View")
        self.controller = controller_factory.create_controller(self)

        self.wx_app = wx.App(False)
        logger.debug("App built")
        self.debug = debug
        self.mark_using_pixels = mark_using_pixels

        self.mainframe = MainFrame(self.controller, track_mode=track_mode)
        self.image_view_manager = ImageViewManager(self.mainframe, zoom)
        self.menu = Menu(self.mainframe, self.controller)
        self.keybind_manager = KeybindManager(self.mainframe, self.controller)

        self.loading_dialog = WaitingGaugeDialog(self.mainframe,
                                                 "Image loading...")

        # Handle user clicking on the window's "x" button
        self.mainframe.Bind(wx.EVT_CLOSE, self._on_close_window)

        self.accept_source_dialog = None
        self.reject_source_dialog = None
        self.certificate_dialog = None
        self.retry_downloads_dialog = None

        # TODO refactor
        self.register_xy_changed_event_handler(self.controller.on_reposition_source)
        logger.debug("Done.")

    def _on_close_window(self, event):
        self.close()

    @property
    def image_viewer(self):
        return self.image_view_manager.image_viewer

    @guithread
    def show(self):
        self.mainframe.Show()

        if self.debug:
            logger.info("Launching view in debug mode.")
            wx.lib.inspection.InspectionTool().Show()

        self.wx_app.MainLoop()

    @guithread
    def display(self, cutout, use_pixel_coords=False):
        self.image_viewer.display(cutout, use_pixel_coords)

    @guithread
    def place_marker(self, cutout, x, y, radius=10, colour='r', force=False):
        self.image_viewer.place_marker(cutout, x, y, radius, colour, force=force)

    @property
    def ds9(self):
        return self.image_viewer.ds9

    @guithread
    def align(self, cutout, reading, source):
        self.image_viewer.align(cutout, reading, source)

    @guithread
    def clear(self):
        self.image_viewer.clear()

    @guithread
    def frame(self, frame):
        return self.image_viewer.ds9.set('frame {}'.format(frame))

    @guithread
    def refresh_markers(self):
        self.image_viewer.refresh_markers()

    @guithread
    def draw_uncertainty_ellipse(self, cutout):
        self.image_viewer.draw_uncertainty_ellipse(cutout)

    @guithread
    def mark_apertures(self, cutout, pixel=False):
        self.image_viewer.mark_apertures(cutout, pixel)

    @guithread
    def reset_colormap(self):
        self.image_viewer.reset_colormap()

    @guithread
    def toggle_reticule(self):
        self.image_viewer.toggle_reticule()

    @guithread
    def register_xy_changed_event_handler(self, handler):
        self.image_viewer.register_xy_changed_event_handler(handler)

    @guithread
    def show_image_loading_dialog(self):
        if not self.loading_dialog.IsShown():
            self.loading_dialog.CenterOnParent()
            self.loading_dialog.Show()

    @guithread
    def hide_image_loading_dialog(self):
        if self.loading_dialog.IsShown():
            self.loading_dialog.Hide()

    @guithread
    def use_singlets(self):
        self.image_view_manager.use_singlets()

    @guithread
    def use_triplets(self):
        self.image_view_manager.use_triplets()

    @guithread
    def update_displayed_data(self, reading_data, header_data_list):
        self.mainframe.update_displayed_data(reading_data, header_data_list)

    @guithread
    def set_observation_status(self, current_obs, total_obs):
        self.mainframe.set_observation_status(current_obs, total_obs)

    @guithread
    def enable_source_validation(self):
        self.mainframe.enable_validation()

    @guithread
    def disable_source_validation(self):
        self.mainframe.disable_validation()

    def is_source_validation_enabled(self):
        return self.mainframe.is_source_validation_enabled()

    @guithread
    def disable_sync_menu(self):
        self.menu.disable_sync()

    @guithread
    def show_certificate_dialog(self, handler, error_message):
        if not self.certificate_dialog:
            self.certificate_dialog = CertificateDialog(self.mainframe,
                                                        handler, error_message)
            self.certificate_dialog.ShowModal()

    @guithread
    def show_retry_download_dialog(self, handler, error_message):
        # Only allow one dialog to be shown at a time
        if not self.retry_downloads_dialog:
            self.retry_downloads_dialog = RetryDownloadDialog(
                self.mainframe, handler, error_message)
            self.retry_downloads_dialog.Show()

    @guithread
    def show_accept_source_dialog(self, provisional_name,
                                  date_of_obs,
                                  ra,
                                  dec,
                                  obs_mag,
                                  obs_mag_err,
                                  band,
                                  note1_choices=None,
                                  note2_choices=None,
                                  note1_default=None,
                                  note2_default=None,
                                  default_observatory_code="",
                                  default_comment="",
                                  phot_failure=False,
                                  pixel_x=None,
                                  pixel_y=None
    ):
        self.accept_source_dialog = AcceptSourceDialog(
            self.mainframe, self.controller,
            provisional_name,
            date_of_obs,
            ra,
            dec,
            obs_mag,
            obs_mag_err,
            band,
            note1_choices=note1_choices,
            note2_choices=note2_choices,
            note1_default=note1_default,
            note2_default=note2_default,
            default_observatory_code=default_observatory_code,
            default_comment=default_comment,
            phot_failure=phot_failure,
            pixel_x=pixel_x,
            pixel_y=pixel_y)
        self.accept_source_dialog.ShowModal()

    @guithread
    def close_accept_source_dialog(self):
        if self.accept_source_dialog is not None:
            self.accept_source_dialog.Close()
            self.accept_source_dialog = None

    @guithread
    def show_vetting_accept_source_dialog(self):
        self.vetting_source_dialog = VettingSourceDialog(
            self.mainframe, self.controller)
        self.vetting_source_dialog.ShowModal()

    @guithread
    def close_vetting_accept_source_dialog(self):
        if self.vetting_source_dialog is not None:
            self.vetting_source_dialog.Close()
            self.vetting_source_dialog = None

    @guithread
    def show_reject_source_dialog(self):
        self.reject_source_dialog = RejectSourceDialog(
            self.mainframe, self.controller)
        self.reject_source_dialog.ShowModal()

    @guithread
    def close_reject_source_dialog(self):
        if self.reject_source_dialog is not None:
            self.reject_source_dialog.Close()
            self.reject_source_dialog = None

    @guithread
    def show_offset_source_dialog(self, cen_coords, pix_coords):
        self.offset_source_dialog = OffsetSourceDialog(
            self.mainframe, self.controller, cen_coords, pix_coords)
        self.offset_source_dialog.ShowModal()

    @guithread
    def close_offset_source_dialog(self):
        if self.offset_source_dialog is not None:
            self.offset_source_dialog.Close()
            self.offset_source_dialog = None

    @guithread
    def show_keymappings(self):
        dialogs.show_keymappings_dialog(self.mainframe, self.keybind_manager)

    @guithread
    def show_empty_workload_dialog(self, directory):
        dialogs.show_empty_workload_dialog(self.mainframe, directory)

    @guithread
    def all_processed_should_exit_prompt(self):
        return dialogs.should_exit_prompt(self.mainframe)

    @guithread
    def set_autoplay(self, autoplay_enabled):
        self.menu.set_autoplay(autoplay_enabled)

    def as_widget(self):
        return self.mainframe

    def close(self):
        self.mainframe.Destroy()
示例#24
0
 def InitUI(self):
     self.frame = MainFrame(None)
     self.frame.Show()
     self.frame.logFrame.Show(True)
示例#25
0
文件: appview.py 项目: OSSOS/MOP
class ApplicationView(object):
    """
    Provides the view's external interface.
    """

    def __init__(self, controller_factory, track_mode=False, debug=False, mark_using_pixels=False, zoom=1):
        logger.debug("Creating Application View")
        self.controller = controller_factory.create_controller(self)

        self.wx_app = wx.App(False)
        logger.debug("App built")
        self.debug = debug
        self.mark_using_pixels = mark_using_pixels

        self.mainframe = MainFrame(self.controller, track_mode=track_mode)
        self.image_view_manager = ImageViewManager(self.mainframe, zoom)
        self.menu = Menu(self.mainframe, self.controller)
        self.keybind_manager = KeybindManager(self.mainframe, self.controller)

        self.loading_dialog = WaitingGaugeDialog(self.mainframe,
                                                 "Image loading...")

        # Handle user clicking on the window's "x" button
        self.mainframe.Bind(wx.EVT_CLOSE, self._on_close_window)

        self.accept_source_dialog = None
        self.reject_source_dialog = None
        self.certificate_dialog = None
        self.retry_downloads_dialog = None

        # TODO refactor
        self.register_xy_changed_event_handler(self.controller.on_reposition_source)
        logger.debug("Done.")

    def _on_close_window(self, event):
        self.close()

    @property
    def image_viewer(self):
        return self.image_view_manager.image_viewer

    @guithread
    def show(self):
        self.mainframe.Show()

        if self.debug:
            logger.info("Launching view in debug mode.")
            wx.lib.inspection.InspectionTool().Show()

        self.wx_app.MainLoop()

    @guithread
    def display(self, cutout, use_pixel_coords=False):
        self.image_viewer.display(cutout, use_pixel_coords)

    @guithread
    def place_marker(self, cutout, x, y, radius=10, colour='r', force=False):
        self.image_viewer.place_marker(cutout, x, y, radius, colour, force=force)

    @property
    def ds9(self):
        return self.image_viewer.ds9

    @guithread
    def align(self, cutout, reading, source):
        self.image_viewer.align(cutout, reading, source)

    @guithread
    def clear(self):
        self.image_viewer.clear()

    @guithread
    def frame(self, frame):
        return self.image_viewer.ds9.set('frame {}'.format(frame))

    @guithread
    def refresh_markers(self):
        self.image_viewer.refresh_markers()

    @guithread
    def draw_uncertainty_ellipse(self, cutout):
        self.image_viewer.draw_uncertainty_ellipse(cutout)

    @guithread
    def mark_apertures(self, cutout, pixel=False):
        self.image_viewer.mark_apertures(cutout, pixel)

    @guithread
    def reset_colormap(self):
        self.image_viewer.reset_colormap()

    @guithread
    def toggle_reticule(self):
        self.image_viewer.toggle_reticule()

    @guithread
    def register_xy_changed_event_handler(self, handler):
        self.image_viewer.register_xy_changed_event_handler(handler)

    @guithread
    def show_image_loading_dialog(self):
        if not self.loading_dialog.IsShown():
            self.loading_dialog.CenterOnParent()
            self.loading_dialog.Show()

    @guithread
    def hide_image_loading_dialog(self):
        if self.loading_dialog.IsShown():
            self.loading_dialog.Hide()

    @guithread
    def use_singlets(self):
        self.image_view_manager.use_singlets()

    @guithread
    def use_triplets(self):
        self.image_view_manager.use_triplets()

    @guithread
    def update_displayed_data(self, reading_data, header_data_list):
        self.mainframe.update_displayed_data(reading_data, header_data_list)

    @guithread
    def set_observation_status(self, current_obs, total_obs):
        self.mainframe.set_observation_status(current_obs, total_obs)

    @guithread
    def enable_source_validation(self):
        self.mainframe.enable_validation()

    @guithread
    def disable_source_validation(self):
        self.mainframe.disable_validation()

    def is_source_validation_enabled(self):
        return self.mainframe.is_source_validation_enabled()

    @guithread
    def disable_sync_menu(self):
        self.menu.disable_sync()

    @guithread
    def show_certificate_dialog(self, handler, error_message):
        if not self.certificate_dialog:
            self.certificate_dialog = CertificateDialog(self.mainframe,
                                                        handler, error_message)
            self.certificate_dialog.ShowModal()

    @guithread
    def show_retry_download_dialog(self, handler, error_message):
        # Only allow one dialog to be shown at a time
        if not self.retry_downloads_dialog:
            self.retry_downloads_dialog = RetryDownloadDialog(
                self.mainframe, handler, error_message)
            self.retry_downloads_dialog.Show()

    @guithread
    def show_accept_source_dialog(self, provisional_name,
                                  date_of_obs,
                                  ra,
                                  dec,
                                  obs_mag,
                                  obs_mag_err,
                                  band,
                                  note1_choices=None,
                                  note2_choices=None,
                                  note1_default=None,
                                  note2_default=None,
                                  default_observatory_code="",
                                  default_comment="",
                                  phot_failure=False,
                                  pixel_x=None,
                                  pixel_y=None
    ):
        self.accept_source_dialog = AcceptSourceDialog(
            self.mainframe, self.controller,
            provisional_name,
            date_of_obs,
            ra,
            dec,
            obs_mag,
            obs_mag_err,
            band,
            note1_choices=note1_choices,
            note2_choices=note2_choices,
            note1_default=note1_default,
            note2_default=note2_default,
            default_observatory_code=default_observatory_code,
            default_comment=default_comment,
            phot_failure=phot_failure,
            pixel_x=pixel_x,
            pixel_y=pixel_y)
        self.accept_source_dialog.ShowModal()

    @guithread
    def close_accept_source_dialog(self):
        if self.accept_source_dialog is not None:
            self.accept_source_dialog.Close()
            self.accept_source_dialog = None

    @guithread
    def show_vetting_accept_source_dialog(self):
        self.vetting_source_dialog = VettingSourceDialog(
            self.mainframe, self.controller)
        self.vetting_source_dialog.ShowModal()

    @guithread
    def close_vetting_accept_source_dialog(self):
        if self.vetting_source_dialog is not None:
            self.vetting_source_dialog.Close()
            self.vetting_source_dialog = None

    @guithread
    def show_reject_source_dialog(self):
        self.reject_source_dialog = RejectSourceDialog(
            self.mainframe, self.controller)
        self.reject_source_dialog.ShowModal()

    @guithread
    def close_reject_source_dialog(self):
        if self.reject_source_dialog is not None:
            self.reject_source_dialog.Close()
            self.reject_source_dialog = None

    @guithread
    def show_offset_source_dialog(self, cen_coords, pix_coords):
        self.offset_source_dialog = OffsetSourceDialog(
            self.mainframe, self.controller, cen_coords, pix_coords)
        self.offset_source_dialog.ShowModal()

    @guithread
    def close_offset_source_dialog(self):
        if self.offset_source_dialog is not None:
            self.offset_source_dialog.Close()
            self.offset_source_dialog = None

    @guithread
    def show_keymappings(self):
        dialogs.show_keymappings_dialog(self.mainframe, self.keybind_manager)

    @guithread
    def show_empty_workload_dialog(self, directory):
        dialogs.show_empty_workload_dialog(self.mainframe, directory)

    @guithread
    def all_processed_should_exit_prompt(self):
        return dialogs.should_exit_prompt(self.mainframe)

    @guithread
    def set_autoplay(self, autoplay_enabled):
        self.menu.set_autoplay(autoplay_enabled)

    def as_widget(self):
        return self.mainframe

    def close(self):
        self.mainframe.Destroy()
示例#26
0
import wx
from mainframe import MainFrame

app = wx.App()

frame = MainFrame(None, title='Flat File Py')
frame.Show()

app.MainLoop()
示例#27
0
class MainWindow(QWidget):
    WIDTH = 800
    HEIGHT = 600

    STATE_NONE = 0
    STATE_GAME_HALL_GAME_LIST = 1
    STATE_GAME_HALL_MAP_LIST = 2
    STATE_GAME_HALL_MAP_SELECTED = 3
    STATE_GAME_HALL_GAME_SELECTED = 4
    STATE_GAME_ROOM_WAITING = 5

    ANIMATION_DEFAULT_AUTO_START = 3000
    ANIMATION_INITIAL_DELAY = 20
    ANIMATION_SHOW_BOTTOM_PANEL_DURATION = 700
    ANIMATION_SHOW_LEFT_PANEL_DURATION = 700
    ANIMATION_SHOW_MAIN_FRAME_DURATION = 700

    def __init__(self):
        super(MainWindow, self).__init__()
        self.setFixedSize(MainWindow.WIDTH, MainWindow.HEIGHT)

        self.mainTitle = Title('Distributed Real-time Risk', 36)
        self.subTitle = Title(' ' * 36 + 'Team 23', 20)

        layout = QGridLayout(self)
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(0)

        assert LeftPanel.OFFSET_Y == MainFrame.OFFSET_Y
        assert LeftPanel.HEIGHT == MainFrame.HEIGHT
        assert LeftPanel.OFFSET_Y + LeftPanel.HEIGHT == BottomPanel.OFFSET_Y
        assert BottomPanel.OFFSET_Y + BottomPanel.HEIGHT == MainWindow.HEIGHT
        layout.setRowStretch(0, LeftPanel.OFFSET_Y)
        layout.setRowStretch(1, LeftPanel.HEIGHT)
        layout.setRowStretch(2, BottomPanel.HEIGHT)

        assert LeftPanel.WIDTH + MainFrame.WIDTH == MainWindow.WIDTH
        layout.setColumnStretch(0, LeftPanel.WIDTH)
        layout.setColumnStretch(1, MainFrame.WIDTH)

        self.leftPanel = LeftPanel()
        self.bottomPanel = BottomPanel()
        self.mainFrame = MainFrame()
        layout.addWidget(self.leftPanel, 1, 0)
        layout.addWidget(self.bottomPanel, 2, 0, 1, -1)
        layout.addWidget(self.mainFrame, 1, 1)

        self.bottomPanel.gameHallControl.backButtonClicked.connect(
            self._onBackButtonClicked)
        self.bottomPanel.gameHallControl.createButtonClicked.connect(
            self._onCreateButtonClicked)
        self.bottomPanel.gameHallControl.joinButtonClicked.connect(
            self._onJoinButtonClicked)
        self.bottomPanel.gameRoomControl.backButtonClicked.connect(
            self._onBackButtonClicked)
        self.bottomPanel.gameRoomControl.startButtonClicked.connect(
            self._onStartButtonClicked)
        self.leftPanel.gameHallPanel.mapList.mapSelected.connect(
            self._onMapSelected)
        self.leftPanel.gameHallPanel.gameList.gameSelected.connect(
            self._onGameSelected)

        self.selectedMap = None
        self.selectedGameLoader = None
        self.selectedGame = None

        self.state = MainWindow.STATE_NONE
        self.initialAnimationStarted = False
        QMetaObject.invokeMethod(self, '_startAnimation', Qt.QueuedConnection)

    @Slot()
    def _startAnimation(self):
        self.leftPanel.hide()
        self.bottomPanel.hide()
        self.mainFrame.hide()

        delayAnimation = QPauseAnimation()
        delayAnimation.setDuration(MainWindow.ANIMATION_INITIAL_DELAY)
        delayAnimation.finished.connect(self.bottomPanel.show)

        showBottomPanelAnimation = QPropertyAnimation(self.bottomPanel, 'pos')
        showBottomPanelAnimation.setDuration(
            MainWindow.ANIMATION_SHOW_BOTTOM_PANEL_DURATION)
        showBottomPanelAnimation.setStartValue(
            self.bottomPanel.pos() + QPoint(0, self.bottomPanel.height()))
        showBottomPanelAnimation.setEndValue(self.bottomPanel.pos())
        showBottomPanelAnimation.setEasingCurve(QEasingCurve.OutExpo)
        showBottomPanelAnimation.finished.connect(self.leftPanel.show)
        showBottomPanelAnimation.finished.connect(self.mainFrame.show)

        parallelAnimationGroup = QParallelAnimationGroup()

        showLeftPanelAnimation = QPropertyAnimation(self.leftPanel, 'pos')
        showLeftPanelAnimation.setDuration(
            MainWindow.ANIMATION_SHOW_LEFT_PANEL_DURATION)
        showLeftPanelAnimation.setStartValue(self.leftPanel.pos() -
                                             QPoint(self.leftPanel.width(), 0))
        showLeftPanelAnimation.setEndValue(self.leftPanel.pos())
        showLeftPanelAnimation.setEasingCurve(QEasingCurve.OutBounce)
        parallelAnimationGroup.addAnimation(showLeftPanelAnimation)

        showMainFrameAnimation = QPropertyAnimation(self.mainFrame, 'pos')
        showMainFrameAnimation.setDuration(
            MainWindow.ANIMATION_SHOW_MAIN_FRAME_DURATION)
        showMainFrameAnimation.setStartValue(self.mainFrame.pos() +
                                             QPoint(self.mainFrame.width(), 0))
        showMainFrameAnimation.setEndValue(self.mainFrame.pos())
        showMainFrameAnimation.setEasingCurve(QEasingCurve.OutBounce)
        parallelAnimationGroup.addAnimation(showMainFrameAnimation)

        self.initialAnimationGroup = QSequentialAnimationGroup()
        self.initialAnimationGroup.addAnimation(delayAnimation)
        self.initialAnimationGroup.addAnimation(showBottomPanelAnimation)
        self.initialAnimationGroup.addAnimation(parallelAnimationGroup)
        self.initialAnimationGroup.finished.connect(self._loadGameHall)

        QTimer.singleShot(MainWindow.ANIMATION_DEFAULT_AUTO_START,
                          self._startInitialAnimation)

    def _startInitialAnimation(self):
        if not self.initialAnimationStarted:
            self.initialAnimationStarted = True
            self.initialAnimationGroup.start(
                QAbstractAnimation.DeleteWhenStopped)

    def _setState(self, state, id=None):
        if self.state == MainWindow.STATE_GAME_HALL_MAP_SELECTED:
            if self.selectedMap is not None:
                self.selectedMap.infoUpdated.disconnect()
                self.selectedMap.parseFinished.disconnect()
                self.selectedMap = None
        elif self.state == MainWindow.STATE_GAME_HALL_GAME_SELECTED:
            if self.selectedGameLoader is not None:
                self.selectedGameLoader.loaded.disconnect()
                self.selectedGameLoader = None
        elif self.state == MainWindow.STATE_GAME_ROOM_WAITING:
            assert self.selectedGame is not None
            if self.mainFrame.gameViewFrame.countDown.t > 0:
                self.mainFrame.gameViewFrame.countDown.finished.disconnect()
            try:
                self.selectedGame.gameMap.parseFinished.disconnect()
            except:
                pass
            self.selectedGame.destroy()
            self.selectedGame = None

        if state == MainWindow.STATE_GAME_HALL_GAME_LIST:
            assert self.state == MainWindow.STATE_NONE or \
                   self.state == MainWindow.STATE_GAME_HALL_MAP_LIST or \
                   self.state == MainWindow.STATE_GAME_HALL_MAP_SELECTED or \
                   self.state == MainWindow.STATE_GAME_ROOM_WAITING
            self.leftPanel.gameHallPanel.showGameList()
            self.leftPanel.showGameHallPanel()
            self.mainFrame.introFrame.setTitle('Distribued Real-time Risk')
            self.mainFrame.introFrame.loading.hide()
            self.mainFrame.showIntroFrame()
            self.bottomPanel.gameHallControl.setAllowBack(False)
            self.bottomPanel.gameHallControl.createButton.setEnabled(True)
            self.bottomPanel.gameHallControl.joinButton.setEnabled(False)
            self.bottomPanel.showGameHallControl()
        elif state == MainWindow.STATE_GAME_HALL_MAP_LIST:
            assert self.state == MainWindow.STATE_GAME_HALL_GAME_LIST or \
                   self.state == MainWindow.STATE_GAME_HALL_GAME_SELECTED
            self.leftPanel.gameHallPanel.showMapList()
            self.leftPanel.showGameHallPanel()
            self.mainFrame.introFrame.setTitle('Create Game')
            self.mainFrame.introFrame.loading.hide()
            self.mainFrame.showIntroFrame()
            self.bottomPanel.gameHallControl.setAllowBack(True)
            self.bottomPanel.gameHallControl.createButton.setEnabled(False)
            self.bottomPanel.gameHallControl.joinButton.setEnabled(False)
        elif state == MainWindow.STATE_GAME_HALL_MAP_SELECTED:
            assert self.state == MainWindow.STATE_GAME_HALL_MAP_LIST or \
                   self.state == MainWindow.STATE_GAME_HALL_MAP_SELECTED
            self.selectedMap = GameMap.getGameMap(id)
            self.selectedMap.infoUpdated.connect(
                self.mainFrame.detailFrame.info.updateInfo,
                Qt.QueuedConnection)
            self.selectedMap.parseFinished.connect(
                self.mainFrame.detailFrame.info.loading.hide,
                Qt.QueuedConnection)
            self.selectedMap.parseFinished.connect(
                self.bottomPanel.gameHallControl.createButton.setEnabled,
                Qt.QueuedConnection)
            self.selectedMap.parseAll()
            self.mainFrame.detailFrame.setTitle(self.selectedMap.mapName)
            self.mainFrame.detailFrame.preview.setImage(
                self.selectedMap.background)
            self.mainFrame.detailFrame.info.updateInfo([])
            self.mainFrame.detailFrame.info.loading.show()
            self.mainFrame.showDetailFrame()
            self.bottomPanel.gameHallControl.createButton.setEnabled(False)
        elif state == MainWindow.STATE_GAME_HALL_GAME_SELECTED:
            assert self.state == MainWindow.STATE_GAME_HALL_GAME_LIST or \
                   self.state == MainWindow.STATE_GAME_HALL_GAME_SELECTED
            assert id is not None
            self.selectedGame = None
            name = self.leftPanel.gameHallPanel.gameList.items[id].text()
            mapId = self.leftPanel.gameHallPanel.gameList.items[id].mapId
            self.selectedGameLoader = GameLoader(
                id, name, mapId,
                self.leftPanel.gameHallPanel.playerName.text())
            self.selectedGameLoader.loaded.connect(self._onGameLoaded)
            self.selectedGameLoader.load()
            self.mainFrame.introFrame.setTitle(self.selectedGameLoader.name)
            self.mainFrame.introFrame.loading.show()
            self.mainFrame.showIntroFrame()
            self.bottomPanel.gameHallControl.joinButton.setEnabled(False)
        elif state == MainWindow.STATE_GAME_ROOM_WAITING:
            assert self.state == MainWindow.STATE_GAME_HALL_GAME_SELECTED or \
                   self.state == MainWindow.STATE_GAME_HALL_MAP_SELECTED
            self.selectedGame.playersUpdated.connect(
                self.leftPanel.gameRoomPanel.playerList.setPlayers)
            self.selectedGame.joined.connect(self._onGameJoined)
            self.selectedGame.joinFailed.connect(self._onGameJoinFailed)
            self.selectedGame.started.connect(self._onGameStarted)
            self.selectedGame.gameMap.parseFinished.connect(
                self._onJoinGameParseFinished)
            self.selectedGame.gameMap.parseAll()
            self.leftPanel.gameRoomPanel.playerList.setPlayers(
                self.selectedGame.players)
            self.leftPanel.gameRoomPanel.setGameName(
                self.selectedGame.gameName)
            self.leftPanel.showGameRoomPanel()
            self.mainFrame.gameViewFrame.setTitle(
                self.selectedGame.gameName + ' : ' +
                self.selectedGame.gameMap.mapName)
            self.mainFrame.gameViewFrame.showLoading()
            self.mainFrame.showGameViewFrame()
            self.bottomPanel.gameHallControl.createButton.setEnabled(False)
            self.bottomPanel.gameRoomControl.startButton.setEnabled(False)
            self.bottomPanel.showGameRoomControl()
        else:
            qFatal('Invalid state %d when trying to set state' % state)
        self.state = state

    @Slot()
    def _loadGameHall(self):
        self._setState(MainWindow.STATE_GAME_HALL_GAME_LIST)

    @Slot()
    def _onBackButtonClicked(self):
        assert self.state == MainWindow.STATE_GAME_HALL_MAP_LIST or \
               self.state == MainWindow.STATE_GAME_HALL_MAP_SELECTED or \
               self.state == MainWindow.STATE_GAME_ROOM_WAITING
        self._setState(MainWindow.STATE_GAME_HALL_GAME_LIST)

    @Slot()
    def _onCreateButtonClicked(self):
        if self.state == MainWindow.STATE_GAME_HALL_GAME_LIST or \
           self.state == MainWindow.STATE_GAME_HALL_GAME_SELECTED:
            self._setState(MainWindow.STATE_GAME_HALL_MAP_LIST)
        elif self.state == MainWindow.STATE_GAME_HALL_MAP_SELECTED:
            self.selectedGame = Game(
                -1, Game.randomGameName(), self.selectedMap,
                self.leftPanel.gameHallPanel.playerName.text())
            self.selectedGame.addPlayer(
                Player(-1, self.leftPanel.gameHallPanel.playerName.text()))
            self.selectedGame.createGame()
            self._setState(MainWindow.STATE_GAME_ROOM_WAITING)
        else:
            qFatal('Invalid state %d when create button clicked' % self.state)

    @Slot()
    def _onJoinButtonClicked(self):
        #self.selectedGame.addPlayer(Player(-1, self.leftPanel.gameHallPanel.playerName.text()))
        self._setState(MainWindow.STATE_GAME_ROOM_WAITING)

    @Slot()
    def _onStartButtonClicked(self):
        self.bottomPanel.gameRoomControl.startButton.setEnabled(False)
        self.selectedGame.startGame()

    @Slot(str)
    def _onMapSelected(self, id):
        self._setState(MainWindow.STATE_GAME_HALL_MAP_SELECTED, id)

    @Slot(str)
    def _onGameSelected(self, id):
        self._setState(MainWindow.STATE_GAME_HALL_GAME_SELECTED, id)

    @Slot()
    def _onGameLoaded(self):
        self.selectedGame = self.selectedGameLoader.game
        playersInfo = [('Players', '')]
        for player in self.selectedGameLoader.players:
            playersInfo.append((player, None))
        self.selectedGameLoader = None
        self.mainFrame.showDetailFrame(False)
        self.mainFrame.detailFrame.setTitle(self.selectedGame.gameName +
                                            ' : ' +
                                            self.selectedGame.gameMap.mapName)
        self.mainFrame.detailFrame.preview.setImage(
            self.selectedGame.gameMap.background)
        self.mainFrame.detailFrame.info.updateInfo(playersInfo)
        self.mainFrame.detailFrame.info.loading.hide()
        self.bottomPanel.gameHallControl.joinButton.setEnabled(True)

    def _loadGameView(self):
        self.mainFrame.gameViewFrame.showGameView(self.selectedGame.gameMap)
        self.selectedGame.updateOwner.connect(
            self.mainFrame.gameViewFrame.gameView.setOwner)
        self.selectedGame.updateArmy.connect(
            self.mainFrame.gameViewFrame.gameView.setArmy)
        self.selectedGame.updateAttack.connect(
            self.mainFrame.gameViewFrame.gameView.setAttack)
        self.selectedGame.updateFlash.connect(
            self.mainFrame.gameViewFrame.gameView.setFlash)
        self.bottomPanel.gameRoomControl.startButton.setEnabled(True)

    @Slot()
    def _onGameJoined(self):
        self.mainFrame.gameViewFrame.setTitle(
            self.selectedGame.gameName + ' : ' +
            self.selectedGame.gameMap.mapName)
        self.leftPanel.gameRoomPanel.playerList.setPlayers(
            self.selectedGame.players)
        assert self.selectedGame.gameMap.parsed == 2
        self._loadGameView()

    @Slot()
    def _onGameJoinFailed(self):
        self.mainFrame.gameViewFrame.setTitle(
            'Sorry... Please try join another game')
        self.mainFrame.gameViewFrame.loading.hide()

    @Slot()
    def _onGameStarted(self):
        self.mainFrame.gameViewFrame.showCountDown(self.selectedGame.ob)
        self.mainFrame.gameViewFrame.countDown.finished.connect(
            self._onGameStartCountDownFinished)

    @Slot()
    def _onGameStartCountDownFinished(self):
        self.mainFrame.gameViewFrame.countDown.finished.disconnect()
        self.hide()
        self.selectedGameWindow = GameWindow(
            self.selectedGame, self.mainFrame.gameViewFrame.gameView)
        self.selectedGameWindow.closed.connect(self._onGameWindowClosed)
        self.selectedGameWindow.statBox.setPlayers(self.selectedGame.players)
        self.mainFrame.gameViewFrame.gameView = None
        self.selectedGameWindow.show()

    @Slot()
    def _onGameWindowClosed(self):
        self.selectedGameWindow.deleteLater()
        self.selectedGameWindow = None
        self.show()
        self._setState(MainWindow.STATE_GAME_HALL_GAME_LIST)

    @Slot()
    def _onJoinGameParseFinished(self):
        self.selectedGame.joinGame()

    def keyPressEvent(self, event):
        self._startInitialAnimation()
        super(MainWindow, self).keyPressEvent(event)

    def mousePressEvent(self, event):
        self._startInitialAnimation()
        super(MainWindow, self).mousePressEvent(event)

    def paintEvent(self, event):
        painter = QPainter()
        painter.begin(self)

        # background
        image = QImage(QDir.currentPath() + '/gui/images/background.png')
        image = image.copy(MainFrame.OFFSET_X, MainFrame.OFFSET_Y,
                           MainFrame.WIDTH, MainFrame.HEIGHT)
        image = image.scaled(self.width(), self.height(), Qt.IgnoreAspectRatio,
                             Qt.SmoothTransformation)
        painter.drawImage(0, 0, image)

        # text
        image = self.mainTitle.titleImage()
        painter.drawImage((self.width() - image.width()) / 2,
                          (self.height() - image.height()) / 2 - 50, image)
        image = self.subTitle.titleImage()
        painter.drawImage((self.width() - image.width()) / 2,
                          (self.height() - image.height()) / 2 + 50, image)

        painter.end()

    def show(self):
        super(MainWindow, self).show()
        rect = QStyle.alignedRect(Qt.LeftToRight, Qt.AlignCenter, self.size(),
                                  QApplication.desktop().availableGeometry())
        self.move(rect.x(), rect.y())
示例#28
0
import wx
from mainframe import MainFrame

app = wx.App()
frame = MainFrame()
app.MainLoop()
示例#29
0
 def showMainFrame(self):
     mainFrame = MainFrame()
     mainFrame.CenterOnScreen()
     mainFrame.Show()
     if self.futureCall.IsRunning():
         self.Raise()
示例#30
0
 def OnInit(self):
     """ Initializes the App """
     self.main_frame = MainFrame(None)
     self.main_frame.Show()
     return True