Changeset 780:1687ac1948d0 in hatta-dev


Ignore:
Timestamp:
07/16/10 20:18:33 (22 months ago)
Author:
Cezary Krzyżanowski <cezary.krzyzanowski@…>
Branch:
default
Message:

Moved ui and png to resources. Get the png packed. Make dialog find it's icon while debugging and when frozen.

Files:
4 edited
2 moved

Legend:

Unmodified
Added
Removed
  • error_dialog.py

    r779 r780  
    99""" 
    1010import sys, os, locale 
     11import os.path 
    1112import pprint 
    1213 
    13 from PyQt4.QtGui import QDialog 
    14 from PyQt4.QtCore import (QString, QThread, pyqtSignal, pyqtSlot, Qt, 
    15     QPoint, QLocale) 
     14from PyQt4.QtGui import QDialog, QPixmap 
     15from PyQt4.QtCore import pyqtSlot, Qt 
    1616 
    1717from ui_errorDialog import Ui_ErrorDialog 
     
    2727class ErrorDialog(QDialog, Ui_ErrorDialog): 
    2828    """ Extends the UI with connectivity. """ 
    29     def __init__(self): 
     29    def __init__(self, module_path): 
    3030        QDialog.__init__(self) 
    3131        self.setupUi(self) 
     32        dist_icon = os.path.join(module_path, 
     33                u'share', u'icons', u'hicolor', u'64x64', u'error.png') 
     34        debug_icon = os.path.join(module_path, u'resources', u'error.png') 
     35        self.error_icon.setPixmap(QPixmap( 
     36                dist_icon if os.path.isfile(dist_icon) else debug_icon)) 
    3237 
    3338        self._caption = None 
  • hatta_qticon.py

    r779 r780  
    3939from error_dialog import ErrorDialog 
    4040 
     41def module_path(): 
     42    """ This will get us the program's directory, 
     43    even if we are frozen using py2exe""" 
     44 
     45    if we_are_frozen(): 
     46        return os.path.dirname(unicode( 
     47            sys.executable, sys.getfilesystemencoding())) 
     48 
     49    return os.path.dirname(unicode(__file__, sys.getfilesystemencoding())) 
     50 
     51 
    4152def we_are_frozen(): 
    4253    """Returns whether we are frozen via py2exe. 
     
    4455 
    4556    return hasattr(sys, "frozen") and sys.frozen == "windows_exe" 
    46  
    47  
    48 def module_path(): 
    49     """ This will get us the program's directory, 
    50     even if we are frozen using py2exe""" 
    51  
    52     if we_are_frozen(): 
    53         return os.path.dirname(unicode( 
    54             sys.executable, sys.getfilesystemencoding())) 
    55  
    56     return os.path.dirname(unicode(__file__, sys.getfilesystemencoding())) 
    57  
    5857 
    5958class HattaThread(QThread): 
     
    278277        # First setup tray icon and display inform user about starting 
    279278        self.hatta_icon = QIcon(QPixmap( 
    280             self.dist_icon if os.path.isfile(self.dist_icon) else  
     279            self.dist_icon if os.path.isfile(self.dist_icon) else 
    281280            self.debug_icon)) 
    282281        self.menu = QMenu(QString(_(u'Hatta Wiki menu'))) 
     
    594593            quote(error_dialog.get_bug_dump())) 
    595594        webbrowser.open(link) 
    596     QApplication.exit() 
     595    #QApplication.exit() 
    597596 
    598597if __name__ == '__main__': 
     
    613612            app = QApplication(sys.argv) 
    614613            QApplication.setQuitOnLastWindowClosed(False) 
    615             error_dialog = ErrorDialog() 
     614            error_dialog = ErrorDialog(module_path()) 
    616615            status_icon = HattaTrayIcon() 
     616            raise AttributeError("DUPA") 
    617617            app.exec_() 
    618618        except Exception as e: 
  • resources/HattaError.ui

    r779 r780  
    8484       <property name="text"> 
    8585        <string/> 
    86        </property> 
    87        <property name="pixmap"> 
    88         <pixmap>error.png</pixmap> 
    8986       </property> 
    9087       <property name="scaledContents"> 
  • setup.py

    r765 r780  
    3434        ('share/locale/sv/LC_MESSAGES', ['locale/sv/LC_MESSAGES/hatta.mo']), 
    3535        ('share/icons/hicolor/scalable', ['resources/hatta.svg']), 
    36         ('share/icons/hicolor/64x64', ['resources/hatta.png']), 
     36        ('share/icons/hicolor/64x64', ['resources/hatta.png', 
     37            'resources/error.png']), 
    3738        ('share/applications', ['resources/hatta.desktop']), 
    3839        ('share/doc/hatta/examples', [ 
     
    4546    requires=['werkzeug (>=0.3)', 'mercurial (>=1.0)', 
    4647             'pybonjour (>=1.1.1)'], 
    47     setup_requires = ['pybonjour'], 
     48    setup_requires=['pybonjour'], 
    4849    classifiers=[ 
    4950        'License :: OSI Approved :: GNU General Public License (GPL)', 
     
    5859        'Environment :: Web Environment', 
    5960    ], 
    60     options = { 
     61    options={ 
    6162        'py2exe': { 
    62                         'includes': ['sip'], 
     63                        'includes': ['sip'], 
    6364            'packages': ['werkzeug', 'dbhash', 'encodings', 
    6465                         'Image', 'pygments'], 
    65             'excludes': ['_ssl', 'tcl', 'tkinter', 'Tkconstants'  
    66                          ,'Tkinter'], 
     66            'excludes': ['_ssl', 'tcl', 'tkinter', 'Tkconstants', 
     67                         'Tkinter'], 
    6768            'dll_excludes': ['tcl84.dll', 'tk84.dll'], 
    6869            "compressed": 1, 
    6970            "optimize": 2, 
    70                         "bundle_files": 1, 
     71                    "bundle_files": 1, 
    7172        }, 
    7273        'py2app': { 
     
    121122                    if 'debug' in file: 
    122123                        print 'removing', file 
    123                         os.remove(os.path.join(root,file)) 
     124                        os.remove(os.path.join(root, file)) 
    124125 
    125126            # And run macdeployqt to copy plugins and build a dmg 
     
    136137elif sys.platform == 'win32': 
    137138    ### Windows installer ### 
    138         # Hack to make py2exe import win32com 
    139         # http://www.py2exe.org/index.cgi/WinShell 
     139        # Hack to make py2exe import win32com 
     140        # http://www.py2exe.org/index.cgi/WinShell 
    140141    # ModuleFinder can't handle runtime changes to __path__, but win32com uses them 
    141142    import time 
     
    238239                from datetime import datetime 
    239240                version = version[:-3] + '.' + datetime.now().strftime('%Y%m%d%H%M') 
    240                  
     241 
    241242            # create the Installer, using the files py2exe has created. 
    242243            script = InnoScript("hatta", lib_dir, dist_dir, 
     
    251252            # Output subdirectory. 
    252253    # class BuildInstaller 
    253      
    254         config['zipfile'] = None 
     254 
     255        config['zipfile'] = None 
    255256    config['cmdclass'] = {"py2exe": BuildInstaller} 
    256257    config['windows'] = [{ 
    257                 'script': 'hatta_qticon.py', 
     258            'script': 'hatta_qticon.py', 
    258259        'icon_resources': [(1, "resources/hatta.ico")], 
    259260    }] 
    260      
     261 
    261262    # Adding MS runtime C libraries 
    262263    if sys.version.startswith('2.6'): 
     
    287288                return 0 
    288289            return origIsSystemDLL(pathname) 
    289         py2exe.build_exe.isSystemDLL = isSystemDLL     
     290        py2exe.build_exe.isSystemDLL = isSystemDLL 
    290291 
    291292else: # Other UNIX-like 
    292293    config['scripts'] = ['hatta_qticon.py', 'hatta_gtkicon.py'] 
    293294 
    294 if __name__=='__main__': 
     295if __name__ == '__main__': 
    295296    setup(**config) 
    296297    try: 
  • ui_errorDialog.py

    r779 r780  
    11# -*- coding: utf-8 -*- 
    22 
    3 # Form implementation generated from reading ui file 'HattaError.ui' 
     3# Form implementation generated from reading ui file 'resources/HattaError.ui' 
    44# 
    5 # Created: Fri Jul 16 19:42:07 2010 
     5# Created: Fri Jul 16 19:56:19 2010 
    66#      by: PyQt4 UI code generator 4.7.3 
    77# 
     
    4242        self.error_icon.setBaseSize(QtCore.QSize(64, 64)) 
    4343        self.error_icon.setText("") 
    44         self.error_icon.setPixmap(QtGui.QPixmap("error.png")) 
    4544        self.error_icon.setScaledContents(False) 
    4645        self.error_icon.setAlignment(QtCore.Qt.AlignLeading|QtCore.Qt.AlignLeft|QtCore.Qt.AlignTop) 
     
    115114        self.error_traceback.setPlainText(QtGui.QApplication.translate("ErrorDialog", "Traceback here.", None, QtGui.QApplication.UnicodeUTF8)) 
    116115        self.details_button.setText(QtGui.QApplication.translate("ErrorDialog", "&Details", None, QtGui.QApplication.UnicodeUTF8)) 
    117  
    118 #import icons_rc 
Note: See TracChangeset for help on using the changeset viewer.