Added an About box.

master
Pacman Ghost 7 years ago
parent 42610a6eb7
commit 6eba63909a
  1. 41
      about_widget.py
  2. 11
      license.txt
  3. 10
      main_window.py
  4. BIN
      resources/pacman-ghost.png
  5. 183
      ui/about_widget.ui

@ -0,0 +1,41 @@
import os
from PyQt5 import uic
from PyQt5.QtWidgets import QDialog , QFrame
from PyQt5.QtGui import QPixmap
from constants import *
import globals
# ---------------------------------------------------------------------
class AboutWidget( QDialog ) :
"""Show an About box."""
def __init__( self , parent ) :
# initialize
super().__init__()
# initialize the widget
uic.loadUi( os.path.join(globals.base_dir,"ui/about_widget.ui") , self )
self.setMinimumSize( self.size() )
self.lbl_app_icon.setPixmap(
QPixmap( os.path.join( globals.base_dir , "resources/app.ico" ) )
)
self.lbl_app_icon.setFrameStyle( QFrame.NoFrame )
self.lbl_app_name.setText( "<html> {} <small>({})</small> </html>".format( APP_NAME , APP_VERSION ) )
self.lbl_avatar.setPixmap(
QPixmap( os.path.join( globals.base_dir , "resources/pacman-ghost.png" ) ) \
.scaled( self.lbl_avatar.size() )
)
self.lbl_avatar.setFrameStyle( QFrame.NoFrame )
# load the dialog
try :
with open( os.path.join( globals.base_dir , "license.txt" ) , "r" ) as fp :
buf = fp.read()
except Exception as ex :
buf = str(ex)
self.lbl_license.setText( buf )
self.lbl_license.setFrameStyle( QFrame.NoFrame )
# connect our handlers
self.btn_ok.clicked.connect( self.close )

@ -0,0 +1,11 @@
This software is provided 'as-is', without any express or implied warranty.
In no event will the author be held liable for any damages arising from the use of this software.
Permission is granted to anyone to use this software for any non-commercial purpose and to alter it and redistribute it freely, subject to the following restrictions:
(*) The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software, an acknowledgment is requested but not required.
(*) Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. Altered source is encouraged to be submitted back to the original author so it can be shared with the community. Please share your changes.
(*) This notice may not be removed or altered from any source distribution.

@ -12,6 +12,7 @@ from constants import *
import globals
from add_card_widget import AddCardWidget
from startup_widget import StartupWidget
from about_widget import AboutWidget
# ---------------------------------------------------------------------
@ -73,6 +74,11 @@ class MainWindow( QMainWindow ) :
action.setStatusTip( "Close the program." )
action.triggered.connect( self.close )
file_menu.addAction( action )
help_menu = menu_bar.addMenu( "&Help" )
about_action = QAction( "&About" , self )
about_action.setStatusTip( "About this program." )
about_action.triggered.connect( self.on_about )
help_menu.addAction( about_action )
# restore the window geometry
buf = globals.app_settings.value( MAINWINDOW_GEOMETRY )
if buf :
@ -240,3 +246,7 @@ class MainWindow( QMainWindow ) :
return
self.tab_widget.removeTab( index )
self._update_ui()
def on_about( self ) :
"""Show an About box."""
AboutWidget( self ).exec_()

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.7 KiB

@ -0,0 +1,183 @@
<?xml version="1.0" encoding="UTF-8"?>
<ui version="4.0">
<class>AboutDialog</class>
<widget class="QDialog" name="AboutDialog">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>508</width>
<height>434</height>
</rect>
</property>
<layout class="QVBoxLayout" name="verticalLayout">
<item>
<widget class="QWidget" name="widget" native="true">
<property name="minimumSize">
<size>
<width>0</width>
<height>50</height>
</size>
</property>
<property name="maximumSize">
<size>
<width>16777215</width>
<height>50</height>
</size>
</property>
<widget class="QLabel" name="lbl_app_icon">
<property name="geometry">
<rect>
<x>0</x>
<y>0</y>
<width>50</width>
<height>50</height>
</rect>
</property>
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="text">
<string/>
</property>
</widget>
<widget class="QLabel" name="lbl_app_name">
<property name="geometry">
<rect>
<x>60</x>
<y>0</y>
<width>281</width>
<height>21</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>16</pointsize>
</font>
</property>
<property name="text">
<string>*** APP NAME ***</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
</widget>
<widget class="QLabel" name="label_2">
<property name="geometry">
<rect>
<x>60</x>
<y>26</y>
<width>121</width>
<height>21</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>8</pointsize>
<italic>true</italic>
</font>
</property>
<property name="text">
<string>&lt;html&gt; written by &lt;i&gt;Pacman Ghost&lt;/i&gt; &lt;/html&gt;</string>
</property>
</widget>
<widget class="QLabel" name="lbl_avatar">
<property name="geometry">
<rect>
<x>180</x>
<y>25</y>
<width>21</width>
<height>21</height>
</rect>
</property>
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="text">
<string/>
</property>
</widget>
</widget>
</item>
<item>
<widget class="QLabel" name="label_3">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&lt;html&gt; Source code is available &lt;a href=&quot;https://github.com/pacman-ghost/asl_cards&quot;&gt;here&lt;/a&gt;. &lt;/html&gt;</string>
</property>
<property name="openExternalLinks">
<bool>true</bool>
</property>
<property name="textInteractionFlags">
<set>Qt::LinksAccessibleByKeyboard|Qt::LinksAccessibleByMouse</set>
</property>
</widget>
</item>
<item>
<widget class="QLabel" name="label_4">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Fixed">
<horstretch>0</horstretch>
<verstretch>0</verstretch>
</sizepolicy>
</property>
<property name="text">
<string>&lt;html&gt; Released under an MIT-like license: &lt;/html&gt;</string>
</property>
</widget>
</item>
<item>
<layout class="QHBoxLayout" name="horizontalLayout">
<property name="leftMargin">
<number>20</number>
</property>
<item>
<widget class="QLabel" name="lbl_license">
<property name="minimumSize">
<size>
<width>0</width>
<height>100</height>
</size>
</property>
<property name="font">
<font>
<pointsize>9</pointsize>
<italic>true</italic>
</font>
</property>
<property name="frameShape">
<enum>QFrame::Box</enum>
</property>
<property name="text">
<string>*** LICENSE ***</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignTop</set>
</property>
<property name="wordWrap">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</item>
<item alignment="Qt::AlignRight">
<widget class="QPushButton" name="btn_ok">
<property name="text">
<string>OK</string>
</property>
<property name="default">
<bool>true</bool>
</property>
</widget>
</item>
</layout>
</widget>
<resources/>
<connections/>
</ui>
Loading…
Cancel
Save