def start_client(): """ Creates the Qt application and shows the main window. """ # create app app = QtWidgets.QApplication([]) # TODO multiple screen support? # test for desktop availability desktop = app.desktop() rect = desktop.screenGeometry() if rect.width() < constants.MINIMAL_SCREEN_SIZE[0] or rect.height() < constants.MINIMAL_SCREEN_SIZE[1]: # noinspection PyTypeChecker QtWidgets.QMessageBox.warning(None, 'Warning', 'Actual screen size below minimal screen size {}.'.format(constants.MINIMAL_SCREEN_SIZE)) return # if no bounds are set, set resonable bounds if tools.get_option(constants.Opt.MAINWINDOW_BOUNDS) is None: tools.set_option(constants.Opt.MAINWINDOW_BOUNDS, desktop.availableGeometry().adjusted(50, 50, -100, -100)) tools.set_option(constants.Opt.MAINWINDOW_MAXIMIZED, True) tools.log_info('No previous bounds of the main window stored, start maximized') # load global stylesheet to app with open(constants.GLOBAL_STYLESHEET_FILE, 'r', encoding='utf-8') as file: style_sheet = file.read() app.setStyleSheet(style_sheet) # setup sound system audio.load_soundtrack_playlist() audio.setup_soundtrack_player() # start audio player if wished if not tools.get_option(constants.Opt.SOUNDTRACK_MUTE): audio.soundtrack_player.play() pass # create client object and switch to start screen client = Client() client.switch_to_start_screen() tools.log_info('client initialized, start Qt app execution') # TODO is this necessary to run as event? # QtCore.QTimer.singleShot(0, network_start) app.exec_()
# You should have received a copy of the GNU General Public License # along with this program. If not, see <http://www.gnu.org/licenses/> import sys import PyQt5.QtWidgets as QtWidgets import imperialism_remake import client.audio as audio import lib.qt as qt def playlist_index_changed(position): print('Next song') qt.Notification(window, 'Next song', positioner=qt.Relative_Positioner().center_horizontal().south(20)) if __name__ == '__main__': app = QtWidgets.QApplication([]) window = QtWidgets.QWidget() window.show() # setup sound system and start playing audio.load_soundtrack_playlist() audio.setup_soundtrack_player() audio.setup_soundtrack_player() audio.soundtrack_playlist.currentIndexChanged.connect(playlist_index_changed) audio.soundtrack_player.play() app.exec_()
import imperialism_remake import client.audio as audio import lib.qt as qt def playlist_index_changed(position): print('Next song') qt.Notification( window, 'Next song', positioner=qt.Relative_Positioner().center_horizontal().south(20)) if __name__ == '__main__': app = QtWidgets.QApplication([]) window = QtWidgets.QWidget() window.show() # setup sound system and start playing audio.load_soundtrack_playlist() audio.setup_soundtrack_player() audio.setup_soundtrack_player() audio.soundtrack_playlist.currentIndexChanged.connect( playlist_index_changed) audio.soundtrack_player.play() app.exec_()