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)
def __init__(self, parent): # DBController.connect(database='S2spot', server="LEC17\FBDSERVER", user='******', password='******') DBController.connect(database='S2spot', server="DESKTOP-LMO6LAE\SQLEXPRESS", user=None, password=None) self.parent = parent self.container = Frame(parent) self.container.pack(fill='both', expand=True) self.right_panel = RightPanel(self.container) Navigate.setContainer(self.right_panel.main_content.container) Navigate.addPage(actived=False, key='rpl', kind='register', label="CADASTRAR PLAYLIST", component=registerplaylist.RegisterPlaylist( Navigate.container)) Navigate.addPage(actived=False, key='rsg', kind='register', label="CADASTRAR FAIXA", component=registersong.RegisterSong( Navigate.container)) Navigate.addPage(actived=False, key='rab', kind='register', label="CADASTRAR ÁLBUM", component=registeralbum.RegisterAlbum( Navigate.container)) Navigate.addPage(actived=False, key='rrd', kind='register', label="CADASTRAR GRAVADORA", component=registerrecord.RegisterRecord( Navigate.container)) Navigate.addPage(actived=False, key='rcp', kind='register', label="CADASTRAR COMPOSITOR", component=registercomposer.RegisterComposer( Navigate.container)) Navigate.addPage(actived=False, key='rmp', kind='register', label="CADASTRAR PERÍODO MUSICAL", component=registerperiod.RegisterPeriod( Navigate.container)) Navigate.addPage(actived=False, key='rit', kind='register', label="CADASTRAR INTÉRPRETE", component=registerinterpreter.RegisterInterpreter( Navigate.container)) Navigate.addPage(actived=False, key='_sg', kind='single', label="FAIXA", component=song.Song(Navigate.container)) Navigate.addPage(actived=False, key='_pl', kind='single', label="PLAYLIST", component=playlist.Playlist(Navigate.container)) Navigate.addPage(actived=False, key='_ab', kind='single', label="ÁLBUM", component=album.Album(Navigate.container)) Navigate.addPage(actived=False, key='sg', kind='list', label="FAIXAS", component=songs.Songs(Navigate.container)) Navigate.addPage(actived=False, key='pl', kind='list', label="PLAYLISTS", component=playlists.Playlists(Navigate.container)) Navigate.addPage(actived=False, key='ab', kind='list', label="ÁLBUNS", component=albums.Albums(Navigate.container)) Navigate.addPage(actived=False, key='rd', kind='list', label="GRAVADORAS", component=records.Records(Navigate.container)) Navigate.addPage(actived=False, key='cp', kind='list', label="COMPOSITORES", component=composers.Composers(Navigate.container)) Navigate.addPage(actived=False, key='mp', kind='list', label="PERÍODOS MUSICAIS", component=periods.Periods(Navigate.container)) Navigate.addPage(actived=False, key='it', kind='list', label="INTÉRPRETES", component=interpreters.Interpreters( Navigate.container)) self.left_panel = LeftPanel(self.container) Navigate.goto('sg') Navigate.setApp(self)
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())
def __init__(self, parent): #stl = (wx.DEFAULT_FRAME_STYLE|wx.MAXIMIZE) & ~( wx.RESIZE_BORDER|wx.RESIZE_BOX|wx.MAXIMIZE_BOX) stl = wx.DEFAULT_FRAME_STYLE wx.Frame.__init__(self, parent, -1, title=app_name, pos=wx.DefaultPosition, size=wx.Size(900, 500), style=stl) wx.Frame.CenterOnScreen(self) #self.SetSize((wx.SystemSettings.GetMetric(wx.SYS_SCREEN_X),wx.SystemSettings.GetMetric(wx.SYS_SCREEN_Y) -70 )) #self.ShowFullScreen(True) #self.SetMinSize(self.GetSize()) self.fileName, self.dirName = "", "" self.doc_name = "" self.t = None # ultilisé pour le lecture des shapes self.doc_loaded = False self.use_grid = False self.current_tab = 0 self.outil_active = [ "", "", "" ] # pour l'affichage de l'outil active dans la barre de status self.stb_spacing = 0 self.reglage = Reglage(parent=self, title="Réglages") self.menubar1 = wx.MenuBar() self.menu1 = wx.Menu() self.menubar1.Append(self.menu1, u"Fichier") self.ouvrir_item = wx.MenuItem(self.menu1, 1, u"Ouvrir\tCtrl+O", wx.EmptyString, wx.ITEM_NORMAL) self.menu1.AppendItem(self.ouvrir_item) self.Bind(wx.EVT_MENU, self.OnFileOpen, self.ouvrir_item) self.menu1.AppendSeparator() self.enregistrer_item = wx.MenuItem(self.menu1, 2, u"Enregistrer\tCtrl+S", wx.EmptyString, wx.ITEM_NORMAL) self.menu1.AppendItem(self.enregistrer_item) self.enregistrer_item.Enable(False) self.Bind(wx.EVT_MENU, self.OnSave, self.enregistrer_item) self.enregistrer_sous_item = wx.MenuItem( self.menu1, 3, u"Enregistrer Sous\tShift+Ctrl+S", wx.EmptyString, wx.ITEM_NORMAL) self.menu1.AppendItem(self.enregistrer_sous_item) self.enregistrer_sous_item.Enable(False) self.Bind(wx.EVT_MENU, self.OnSaveAs, self.enregistrer_sous_item) self.reglage_item = wx.MenuItem(self.menu1, 4, u"Réglages\tCtrl+R", wx.EmptyString, wx.ITEM_NORMAL) self.menu1.AppendItem(self.reglage_item) self.reglage_item.Enable(False) self.Bind(wx.EVT_MENU, self.OnReglage, self.reglage_item) self.menu1.AppendSeparator() self.quitter_item = wx.MenuItem(self.menu1, 5, u"Quitter\tCtrl+Q") self.quitter_item.SetBitmap(wx.Bitmap('exit2.png')) self.menu1.AppendItem(self.quitter_item) self.Bind(wx.EVT_MENU, self.OnQuit, self.quitter_item) # 2eme menu : view menu view_menu = wx.Menu() self.menubar1.Append(view_menu, u"Affichage") self.voir_tbar = wx.MenuItem(view_menu, wx.ID_ANY, u"Voir La barre d'outil\tShift+Ctrl+T", wx.EmptyString, wx.ITEM_CHECK) self.voir_stbar = wx.MenuItem( view_menu, wx.ID_ANY, u"Voir La barre de status\tShift+Ctrl+S", wx.EmptyString, wx.ITEM_CHECK) view_menu.AppendItem(self.voir_tbar) view_menu.AppendItem(self.voir_stbar) view_menu.Check(self.voir_tbar.GetId(), True) view_menu.Check(self.voir_stbar.GetId(), True) self.Bind(wx.EVT_MENU, self.ApparenceToolBar, self.voir_tbar) self.Bind(wx.EVT_MENU, self.ApparenceStatusBar, self.voir_stbar) """ self.outils_menu = wx.Menu() self.menubar1.Append( self.outils_menu, u"Outils" ) self.vue_initiale_item = wx.MenuItem( self.outils_menu, wx.ID_ANY, u"Vue Initiale",wx.EmptyString) self.outils_menu.AppendItem(self.vue_initiale_item) self.Bind(wx.EVT_MENU,self.OnHome, self.vue_initiale_item) """ #self.grid_item = wx.MenuItem( self.option_menu, wx.ID_ANY, u"Show Grid",wx.EmptyString, wx.ITEM_CHECK) #self.option_menu.AppendItem(self.grid_item) #self.Bind(wx.EVT_MENU,self.OnShowGrid, self.grid_item) self.aide_menu = wx.Menu() self.menubar1.Append(self.aide_menu, u"Aide") self.aide_item = wx.MenuItem(self.aide_menu, wx.ID_ANY, u"Aide\tF1") self.aide_menu.AppendItem(self.aide_item) self.Bind(wx.EVT_MENU, self.OnAide, self.aide_item) self.short_cut_item = wx.MenuItem(self.aide_menu, wx.ID_ANY, u"Raccourcis Clavier\tF2") self.aide_menu.AppendItem(self.short_cut_item) self.Bind(wx.EVT_MENU, self.OnShowShortCut, self.short_cut_item) self.aide_menu.AppendSeparator() self.about_item = wx.MenuItem(self.aide_menu, wx.ID_ANY, u"À propos\tF3") self.aide_menu.AppendItem(self.about_item) self.Bind(wx.EVT_MENU, self.OnAbout, self.about_item) self.SetMenuBar(self.menubar1) self.toolbar = self.CreateToolBar(style=wx.BORDER | wx.TB_HORIZONTAL | wx.TB_FLAT) #|wx.TB_TEXT) self.toolbar.SetBackgroundColour( "white") #wx.SystemSettings.GetColour(wx.SYS_COLOUR_MENUBAR)) self.toolbar.SetToolBitmapSize((32, 32)) ouvrir_tool = self.toolbar.AddLabelTool(2, 'Ouvrir', wx.Bitmap('document_open.png'), shortHelp="Ouvrir") self.toolbar.AddSeparator() enreg_tool = self.toolbar.AddLabelTool(3, 'Enregistrer', wx.Bitmap('save.png'), shortHelp="Enregistrer") enreg_sous_tool = self.toolbar.AddLabelTool( 4, 'Enregistrer Sous', wx.Bitmap('save_as5.png'), shortHelp="Enregistrer Sous") reglage_tool = self.toolbar.AddLabelTool(77, u'Réglages', wx.Bitmap('reglage2.png'), shortHelp=u"Réglages") self.toolbar.AddSeparator() quit_tool = self.toolbar.AddLabelTool(1, 'Quitter', wx.Bitmap('exit.png'), shortHelp="Quitter") self.toolbar.AddSeparator() home_tool = self.toolbar.AddLabelTool( 5, 'Home', wx.Bitmap('home.png'), shortHelp= "Vue Initial : Annuler toutes les actions appliqué sur la figure") export_image_tool = self.toolbar.AddLabelTool( 10, 'Export', wx.Bitmap('Image.png'), shortHelp="Exporter :\nExporter la figure sous forme d'image" ) #'export_as_image2.png' , 'childish_Image.png' undo_tool = self.toolbar.AddLabelTool( 6, 'Undo', wx.Bitmap('prev.png'), shortHelp="Annuler :\nAnnuler une à une vos actions") redo_tool = self.toolbar.AddLabelTool( 7, 'Redo', wx.Bitmap('next.png'), shortHelp="Rétablir :\nRefaire une à une vos actions annulées") self.toolbar.AddSeparator() pan_tool = self.toolbar.AddLabelTool( 9, 'Pan', wx.Bitmap('hand_tool.png'), shortHelp= "Déplacer :\nFaire déplacer la figure présente dans le canevas de dessin " ) zoom_tool = self.toolbar.AddLabelTool( 8, 'Zoom', wx.Bitmap('zoom_in3.png'), shortHelp= "Zoomer :\nCréer un rectangle de zoom en cliquant droit sur une place de la vue Graphique et tirant la souris jusqu’au sommet opposé du rectangle désiré" ) #self.rect_selection_tool = self.toolbar.AddLabelTool(11,'Rectangle_Selection', wx.Bitmap('selection-resize.png'), shortHelp="Selection") self.rect_selection_tool = self.toolbar.AddLabelTool( 11, 'Rectangle_Selection', wx.Bitmap('selection-resize.png'), shortHelp= "Sélectionner :\nPour selectionner un morceu de la carte, en maintenant le bouton gauche de la souris enfoncé, déplacez le curseur jusqu’au coin opposé " ) self.toolbar.EnableTool(3, False) self.toolbar.EnableTool(4, False) self.toolbar.EnableTool(5, False) self.toolbar.EnableTool(6, False) self.toolbar.EnableTool(7, False) self.toolbar.EnableTool(8, False) self.toolbar.EnableTool(9, False) self.toolbar.EnableTool(10, False) self.toolbar.EnableTool(11, False) self.toolbar.EnableTool(77, False) self.toolbar.Realize() self.toolbar.Bind(wx.EVT_TOOL, self.OnQuit, quit_tool) self.toolbar.Bind(wx.EVT_TOOL, self.OnFileOpen, ouvrir_tool) self.toolbar.Bind(wx.EVT_TOOL, self.OnSave, enreg_tool) self.toolbar.Bind(wx.EVT_TOOL, self.OnSaveAs, enreg_sous_tool) self.toolbar.Bind(wx.EVT_TOOL, self.OnReglage, reglage_tool) self.toolbar.Bind(wx.EVT_TOOL, self.OnUndo, undo_tool) self.toolbar.Bind(wx.EVT_TOOL, self.OnRedo, redo_tool) self.toolbar.Bind(wx.EVT_TOOL, self.OnPan, pan_tool) self.toolbar.Bind(wx.EVT_TOOL, self.OnZoom, zoom_tool) self.toolbar.Bind(wx.EVT_TOOL, self.OnHome, home_tool) self.toolbar.Bind(wx.EVT_TOOL, self.OnExportImage, export_image_tool) self.toolbar.Bind(wx.EVT_TOOL, self.OnRectangleSelection, self.rect_selection_tool) self.st = wx.StatusBar(self) self.SetStatusBar(self.st) self.StatusBarUpdater("") self.splitter = wx.SplitterWindow( self, -1, style=wx.SP_3DSASH | wx.SP_LIVE_UPDATE) #|wx.SP_PERMIT_UNSPLIT) self.leftpanel = LeftPanel(self.splitter) self.rightpanel = RightPanel(self.splitter) self.splitter.SplitVertically(self.leftpanel, self.rightpanel) self.splitter.SetMinimumPaneSize(self.leftpanel.sb.GetSize()[0] + 15) self.Bind(wx.EVT_SIZE, self.OnResize) sizer = wx.BoxSizer(wx.HORIZONTAL) sizer.Add(self.splitter, 1, wx.EXPAND) self.SetSizer(sizer) self.Show(True) #self.SetMinSize(self.GetSize()) self.Maximize(True) self.Centre(wx.BOTH)