Coverage for src/scrilla/gui/main.py: 0%

34 statements  

« prev     ^ index     » next       coverage.py v6.4.2, created at 2022-07-18 18:14 +0000

1# This file is part of scrilla: https://github.com/chinchalinchin/scrilla. 

2 

3# scrilla is free software: you can redistribute it and/or modify 

4# it under the terms of the GNU General Public License version 3 

5# as published by the Free Software Foundation. 

6 

7# scrilla is distributed in the hope that it will be useful, 

8# but WITHOUT ANY WARRANTY; without even the implied warranty of 

9# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 

10# GNU General Public License for more details. 

11 

12# You should have received a copy of the GNU General Public License 

13# along with scrilla. If not, see <https://www.gnu.org/licenses/> 

14# or <https://github.com/chinchalinchin/scrilla/blob/develop/main/LICENSE>. 

15 

16import sys 

17import argparse 

18 

19from PySide6 import QtWidgets, QtGui 

20from scrilla import settings 

21from scrilla.util import outputter 

22from scrilla.gui import formats 

23import scrilla.gui.widgets.menu as menu 

24 

25logger = outputter.Logger('main', settings.LOG_LEVEL) 

26 

27 

28def parse_dimensions(): 

29 parser = argparse.ArgumentParser() 

30 parser.add_argument('--full-screen', '-full-screen', '--full', 

31 '-full', action='store_true', dest='full_screen') 

32 parser.add_argument('--width', '-width', '--w', type=int, 

33 dest='width', default=settings.GUI_WIDTH) 

34 parser.add_argument('--height', '-height', '--h', type=int, 

35 dest='height', default=settings.GUI_HEIGHT) 

36 return vars(parser.parse_args()) 

37 

38 

39def do_gui(): 

40 dimensions = parse_dimensions() 

41 

42 app = QtWidgets.QApplication([]) 

43 

44 widget = menu.MenuWidget() 

45 

46 with open(settings.GUI_STYLESHEET_FILE, "r") as f: 

47 _style = formats.format_stylesheet(f.read()) 

48 print(_style) 

49 app.setStyleSheet(_style) 

50 

51 logger.verbose(f'Initializing GUI with style sheet: {_style}', 'do_gui') 

52 

53 if not dimensions['full_screen']: 

54 widget.resize(dimensions['width'], dimensions['height']) 

55 center = QtGui.QScreen.availableGeometry( 

56 QtWidgets.QApplication.primaryScreen()).center() 

57 geo = widget.frameGeometry() 

58 geo.moveCenter(center) 

59 widget.move(geo.topLeft()) 

60 widget.show() 

61 

62 else: 

63 widget.showFullScreen() 

64 

65 sys.exit(app.exec_()) 

66 

67 

68if __name__ == "__main__": 

69 do_gui()