Example #1
0
class Application(QApplication):
    SELF_HOST, SELF_PORT = 'localhost', 13333
    SERVER_HOST, SERVER_PORT = 'localhost', 13334
    MUSIC_DIR = 'd:\music'

    def __init__(self, argv):
        QApplication.__init__(self, argv)
        log_level = logging.DEBUG if 1 == 1 else logging.INFO
        logging.basicConfig(level=log_level,format='%(name)s: %(message)s')
        self.logger = logging.getLogger('Application')

        port = self.SELF_PORT
        if len(argv) > 1:
            port = int(argv[1])
        self.network = NetworkThread((self.SELF_HOST, port))
        client = False
        if port != self.SERVER_PORT:
            client = True
            self.network.server.connectPeer((self.SERVER_HOST, self.SERVER_PORT))
        self.file_indexer = FileIndexer(self.MUSIC_DIR)
        self.file_indexer.start()

        if client:
            self.database = Database('client_media_db')
        else:
            self.database = Database()

        self.main_window = MainWindow(self.network)
        self.main_window.show()

        self.network.server.musicFound.connect(self.main_window.tracklist_model.setTrackList)
Example #2
0
def main():
    """Creates and runs the PriceChartingTool application."""

    # Parse command-line arguments.
    (options, args) = parseCommandlineArgs()
    
    # Set up the logger.
    
    # Parsing the log config file doesn't work on the current version
    # of cx_Freeze (on Windows and on Mac).  The author of cx_Freeze
    # knows about this bug and hopefully the next release of cx_Freeze
    # addresses this issue.  Until then, only parse the config file if
    # this file is referenced as a .py file.
    if sys.argv[0].split(".")[-1] == "py":
        logging.config.fileConfig(LOG_CONFIG_FILE)
    log = logging.getLogger("main")

    log.info("##########################################");
    log.info("# Starting " + sys.argv[0] + ", version " + APP_VERSION);
    log.info("##########################################");

    # Create the Qt application.
    app = QApplication(sys.argv)
    app.setApplicationName(APP_NAME)
    app.setWindowIcon(QIcon(":/images/rluu/appIcon.png"))

    # Turn off UIEffects so that the application runs faster when doing
    # X11 forwarding.
    app.setEffectEnabled(Qt.UI_AnimateMenu, False)
    app.setEffectEnabled(Qt.UI_FadeMenu, False)
    app.setEffectEnabled(Qt.UI_AnimateCombo, False)
    app.setEffectEnabled(Qt.UI_AnimateTooltip, False)
    app.setEffectEnabled(Qt.UI_FadeTooltip, False)
    app.setEffectEnabled(Qt.UI_AnimateToolBox, False)
    
    # Initialize the Ephemeris.
    Ephemeris.initialize()

    # Set a default location (required).
    Ephemeris.setGeographicPosition(-77.084444, 38.890277)
    
    # Create the main window for the app and show it.
    mainWindow = MainWindow(APP_NAME, 
                            APP_VERSION, 
                            APP_DATE, 
                            APP_AUTHOR, 
                            APP_AUTHOR_EMAIL)
    mainWindow.show()

    # Cleanup and close the application when the last window is closed.
    app.lastWindowClosed.connect(Ephemeris.closeEphemeris)
    app.lastWindowClosed.connect(logging.shutdown)
    app.lastWindowClosed.connect(app.quit)

    return app.exec_()
Example #3
0
	def __init__(self, *args, **kwargs):
		MainWindowBase.__init__(self, *args, **kwargs)
		
		self.Bind(wx.EVT_CLOSE, self.on_close, self)
		
		self.set_connected(False)
		
		timer_id = 100
		self.update_timer = wx.Timer(self, timer_id)
		wx.EVT_TIMER(self, timer_id, self.on_timer)
		self.update_timer.Start(1000)
Example #4
0
def main():
   app = QtGui.QApplication(sys.argv)

   #scene = BattlefieldScene()
   w = MainWindow()
   w.show()

   sys.exit(app.exec_())
   
#   rh = RollHandler("20d6 5+ 4+")
#   print rh.commandString
#   rh.Roll()
   return
Example #5
0
def main():
   #============================================================================
   # check if the program is already running
   #============================================================================
   pid = str(os.getpid())
   pidfile = "~firestarter.pid"
   
   running = False
   
   if os.path.isfile(pidfile):         # pid file available?
      with open(pidfile, 'r') as pf:
         oldpid = pf.readlines()[0]
         if pidRunning(oldpid):   # process with pid still alive?
            running = True
   
   if running: sys.exit()
   else:
      with open(pidfile, 'w') as pf: pf.write(pid)
      
   #============================================================================
   # verify directory structure
   #============================================================================
   neededFolders = ("cache", "cache/icons", "cache/steam", "export")
   for folder in neededFolders:
      if not os.path.isdir(folder):
         os.makedirs(folder)

   #============================================================================
   # Start main program
   #============================================================================
   ret = MainWindow.RestartCode
   while ret == MainWindow.RestartCode:
      flushLogfiles(("parser.log","steamapi.log"), 'utf-8')
      
      app = QtGui.QApplication(sys.argv)
      # run program
      mainWnd = MainWindow()
      mainWnd.show()
      
      ret = app.exec_()
      
      del mainWnd
      del app

   #============================================================================
   # cleanup and exit
   #============================================================================
   os.remove(pidfile)
   sys.exit(ret)
 def __init__(self):
     '''
     Constructor
     '''
     qt4.QObject.__init__( self )
             
     self.view_mode = "R"        
     
     self.cp1 = CircuitProfile(None)
     self.cp2 = CircuitProfile(None)
     self.cpgoal = CircuitProfile(None)
     
     self.ops = {}
     self.results = {"S1": {}, "S2": {}, "Change": {}, "Goal": {}}
     
     self.load_operations()
     # create the GUI app
     self.app = qt4.QApplication.instance()
     self.app.processEvents()
     # instantiate the main window
     self.ui = MainWindow(self)
     self.plots_S1 = Plots(self, self.ui, "S1", self.ui.mplS1)
     self.plots_S2 = Plots(self, self.ui, "S2", self.ui.mplS2)
     self.plots_S2.hide()
     # full screen
     self.ui.showMaximized()
     # start the Qt main loop execution, exiting from this script
     # with the same return code of Qt application
     sys.exit(self.app.exec_())
     
     self.log_file = open("log_file.txt", "w")
Example #7
0
File: anm.py Project: yeleman/anm
def main():

    gettext_windows.setup_env()

    locale.setlocale(locale.LC_ALL, '')

    gettext.install('anm', localedir='locale', unicode=True)

    # ensure DB is in place
    fixture_data.initial_setup()

    app = QtGui.QApplication(sys.argv)
    window = MainWindow()
    setattr(ANMWindow, 'window', window)
    window.show()
    #window.showMaximized()
    sys.exit(app.exec_())
Example #8
0
	def __init__(self, *args, **kwargs):
		MainWindowBase.__init__(self, *args, **kwargs)
		
		self.arduino = None
		
		# Load the serial port name
		try:
			serial_port = open("serial_port.conf", "r").read()
		except IOError:
			serial_port = ""
		self.serial_port.ChangeValue(serial_port)
		
		# Connect to the arduino
		try:
			self.connect()
		except:
			pass # Oh well...
		
		self._last_connected = 0
Example #9
0
File: main.py Project: rluu/iching
def main():
    # Parse command-line arguments.
    (options, args) = parseCommandlineArgs()
    
    # Set up the logger.

    # Parsing the log config file doesn't work on the current version
    # of cx_Freeze (on Windows and on Mac).  The author of cx_Freeze
    # knows about this bug and hopefully the next release of cx_Freeze
    # addresses this issue.  Until then, only parse the config file if
    # this file is referenced as a .py file.
    if sys.argv[0].split(".")[-1] == "py":
        logging.config.fileConfig(LOG_CONFIG_FILE)
    log = logging.getLogger("main")

    log.info("##########################################");
    log.info("# Starting " + sys.argv[0] + ", version " + APP_VERSION);
    log.info("##########################################");

    # Create the Qt application.
    app = QApplication(sys.argv)
    app.setApplicationName(APP_NAME)
    app.setWindowIcon(QIcon(":/images/rluu/appIcon.png"))

    # Create the main window for the app and show it.
    mainWindow = MainWindow(APP_NAME, 
                            APP_VERSION, 
                            APP_DATE, 
                            APP_AUTHOR, 
                            APP_AUTHOR_EMAIL)
    mainWindow.show()

    # Cleanup and close the application when the last window is closed.
    app.lastWindowClosed.connect(logging.shutdown)
    app.lastWindowClosed.connect(app.quit)

    return app.exec_()
Example #10
0
    def __init__(self):
        # load config
        cfg.init(None)

        # main window
        self._app = QtWidgets.QApplication(sys.argv)
        self._app.setWindowIcon(icon.get_app_icon("me-geomap"))
        self.mainwindow = MainWindow(self)
        cfg.main_window = self.mainwindow

        # set default values
        self._update_document_name()

        # show
        self.mainwindow.show()
Example #11
0
def run():
    w = MainWindow()
    w.show(dockable=True, floating=False, area='left')
Example #12
0
#TODO don't have this as a global
mainWindow = None

if __name__ == '__main__':
  parser = argparse.ArgumentParser(description='BraidsTag server.')
  args = parser.parse_args()

  gameState = ServerGameState()

  main = ListeningThread(gameState)
  main.start()

  # Create Qt application
  app = QApplication(sys.argv)
  mainWindow = MainWindow(gameState, main)
  mainWindow.show()

  # Enter Qt main loop
  retval = app.exec_()

  for i in gameState.players.values():
    print(i)

  main.stop()
  gameState.terminate()

  #print >> sys.stderr, "\n*** STACKTRACE - START ***\n"
  #code = []
  #for threadId, stack in sys._current_frames().items():
  #    code.append("\n# ThreadID: %s" % threadId)
Example #13
0
#!/usr/bin/python 
# -*- coding: utf-8 -*-

import os, sys, locale, os.path
from PyQt4 import QtGui, QtCore
from ui import MainWindow
from Functions import InitConfigValue, createStructure

locale.setlocale(locale.LC_ALL, 'C')
createStructure()
app = QtGui.QApplication(sys.argv)
os.chdir(os.path.split(sys.argv[0])[0])
pixmap = QtGui.QPixmap ('..' + os.sep + 'icons' + os.sep + 'tux_partizan.png')
splash = QtGui.QSplashScreen (pixmap, QtCore.Qt.WindowStaysOnTopHint)
splash.show()
app.processEvents()
main = MainWindow()
if InitConfigValue(main.Settings, 'RunInTray', 'False') == 'True' :
	main.hide()
else :
	main.show()
#splash.showMessage(" 00001\n", QtCore.Qt.AlignCenter, QtCore.Qt.yellow)
#app.processEvents()
splash.finish(main)
sys.exit(app.exec_())
Example #14
0
class ModelEditor:
    """Model editor main class"""

    def __init__(self):
        # load config
        cfg.init(None)

        # main window
        self._app = QtWidgets.QApplication(sys.argv)
        self._app.setWindowIcon(icon.get_app_icon("me-geomap"))
        self.mainwindow = MainWindow(self)
        cfg.main_window = self.mainwindow

        # set default values
        self._update_document_name()

        # show
        self.mainwindow.show()

    def new_file(self):
        """new file menu action"""
        if not self.save_old_file():
            return
        cfg.new_file()
        self.mainwindow.reload()
        self.mainwindow.update_recent_files(0)
        self._update_document_name()
        self.mainwindow.info.update_from_data({'record_id': cfg.root_input_type['id']})
        self.mainwindow.show_status_message("New file is opened")

    def open_file(self):
        """open file menu action"""
        if not self.save_old_file():
            return
        yaml_file = QtWidgets.QFileDialog.getOpenFileName(
            self.mainwindow, "Choose Yaml Model File",
            cfg.config.last_data_dir, "Yaml Files (*.yaml)")
        if yaml_file[0]:
            cfg.open_file(yaml_file[0])
            self.mainwindow.reload()
            self.mainwindow.update_recent_files()
            self._update_document_name()
            self.mainwindow.show_status_message("File '" + yaml_file[0] + "' is opened")

    def import_file(self):
        """import con file menu action"""
        if not self.save_old_file():
            return
        con_file = QtWidgets.QFileDialog.getOpenFileName(
            self.mainwindow, "Choose Con Model File",
            cfg.config.last_data_dir, "Con Files (*.con)")
        if con_file[0]:
            cfg.import_file(con_file[0])
            self.mainwindow.reload()
            self.mainwindow.update_recent_files()
            self._update_document_name()
            self.mainwindow.show_status_message("File '" + con_file[0] + "' is imported")

    def open_recent(self, action):
        """open recent file menu action"""
        if action.text() == cfg.curr_file:
            return
        if not self.save_old_file():
            return
        cfg.open_recent_file(action.text())
        self.mainwindow.reload()
        self.mainwindow.update_recent_files()
        self._update_document_name()
        self.mainwindow.show_status_message("File '" + action.text() + "' is opened")

    def save_file(self):
        """save file menu action"""
        if cfg.curr_file is None:
            return self.save_as()
        cfg.update_yaml_file(self.mainwindow.editor.text())
        cfg.save_file()
        self.mainwindow.show_status_message("File is saved")

    def save_as(self):
        """save file menu action"""
        cfg.update_yaml_file(self.mainwindow.editor.text())
        if cfg.curr_file is None:
            if cfg.imported_file_name is not None:
                new_file = cfg.imported_file_name
            else:
                new_file = cfg.config.last_data_dir + os.path.sep + "NewFile.yaml"
        else:
            new_file = cfg.curr_file
        dialog = QtWidgets.QFileDialog(self.mainwindow, 'Save as YAML File', new_file,
                                       "YAML Files (*.yaml)")
        dialog.setDefaultSuffix('.yaml')
        dialog.setFileMode(QtWidgets.QFileDialog.AnyFile)
        dialog.setAcceptMode(QtWidgets.QFileDialog.AcceptSave)
        dialog.setViewMode(QtWidgets.QFileDialog.Detail)
        if dialog.exec_():
            file_name = dialog.selectedFiles()[0]
            cfg.save_as(file_name)
            self.mainwindow.update_recent_files()
            self._update_document_name()
            self.mainwindow.show_status_message("File is saved")
            return True
        return False

    def transform(self, file):
        """Run transformation according rules in set file"""
        cfg.update_yaml_file(self.mainwindow.editor.text())
        cfg.transform(file)
        # synchronize cfg document with editor text
        self.mainwindow.editor.setText(cfg.document, keep_history=True)
        self.mainwindow.reload()

    def edit_transformation_file(self, file):
        """edit transformation rules in file"""
        text = cfg.get_transformation_text(file)
        if text is not None:
            dlg = JsonEditorDlg(cfg.transformation_dir, file,
                                "Transformation rules:", text, self.mainwindow)
            dlg.exec_()

    def select_format(self, filename):
        """Selects format file by filename."""
        if cfg.curr_format_file == filename:
            return
        cfg.curr_format_file = filename
        cfg.update_format()
        self.mainwindow.reload()
        self.mainwindow.show_status_message("Format of file is changed")

    def edit_format(self):
        """Open selected format file in Json Editor"""
        text = cfg.get_curr_format_text()
        if text is not None:
            dlg = JsonEditorDlg(cfg.format_dir, cfg.curr_format_file,
                                "Format", text, self.mainwindow)
            dlg.exec_()

    def _update_document_name(self):
        """Update document title (add file name)"""
        title = "GeoMop Model Editor"
        if cfg.curr_file is None:
            title += " - New File"
        else:
            title += " - " + cfg.curr_file
        self.mainwindow.setWindowTitle(title)

    def save_old_file(self):
        """
        If file not saved, display confirmation dialeg and if is needed, do it

        return: False if action have to be aborted
        """
        cfg.update_yaml_file(self.mainwindow.editor.text())
        if cfg.changed:
            msg_box = QMessageBox()
            msg_box.setWindowTitle("Confirmation")
            msg_box.setIcon(QMessageBox.Question)
            msg_box.setStandardButtons(QMessageBox.Yes | QMessageBox.No | QMessageBox.Abort)
            msg_box.setDefaultButton(QMessageBox.Abort)
            msg_box.setText("The document has unsaved changes, do you want to save it?")
            reply = msg_box.exec_()

            if reply == QtWidgets.QMessageBox.Abort:
                return False
            if reply == QtWidgets.QMessageBox.Yes:
                if cfg.curr_file is None:
                    return self.save_as()
                else:
                    self.save_file()
        return True

    def main(self):
        """go"""
        self._app.exec_()
Example #15
0
class Model(qt4.QObject):
    '''
    
    Main work horse. Model of the data.
    '''  
    
    #*************************************__init__()************************************* 
    def __init__(self):
        '''
        Constructor
        '''
        qt4.QObject.__init__( self )
                
        self.view_mode = "R"        
        
        self.cp1 = CircuitProfile(None)
        self.cp2 = CircuitProfile(None)
        self.cpgoal = CircuitProfile(None)
        
        self.ops = {}
        self.results = {"S1": {}, "S2": {}, "Change": {}, "Goal": {}}
        
        self.load_operations()
        # create the GUI app
        self.app = qt4.QApplication.instance()
        self.app.processEvents()
        # instantiate the main window
        self.ui = MainWindow(self)
        self.plots_S1 = Plots(self, self.ui, "S1", self.ui.mplS1)
        self.plots_S2 = Plots(self, self.ui, "S2", self.ui.mplS2)
        self.plots_S2.hide()
        # full screen
        self.ui.showMaximized()
        # start the Qt main loop execution, exiting from this script
        # with the same return code of Qt application
        sys.exit(self.app.exec_())
        
        self.log_file = open("log_file.txt", "w")

    #*************************************load_circuit_profile()************************************* 
    def load_circuit_profile(self, identifier, fname):
        '''
        
        Args: 
        Returns:
        Raises:
        '''  
        if identifier == "S1":
            cp = self.cp1
        elif identifier == "S2":
            cp = self.cp2
            self.plots_S2.unhide()
            if len(cp.results) == 0:
                self.plots_S1.hide()
        elif identifier == "Goal":
            cp = self.cpgoal
        else:
            print "Unknown circuit profile identifier"
            sys.exit()
        
        cp.open_file(fname)
        results = self.compute_operations(cp)
        cp.set_results(results)
        self.results[identifier] = results
        
        if identifier == "S1":
            self.plots_S1.update_plots(cp)
        elif identifier == "S2":
            self.plots_S2.update_plots(cp)
                    
        self.check_change()
        self.emit(qt4.SIGNAL("sigModified"))
        
        
    #***************************check_change()***************************
    def check_change(self):
        '''
        
        Args: 
        Returns:
        Raises:
        '''
        rS1 = self.results["S1"]
        rS2 = self.results["S2"]
        
        if len(rS1) > 0 and len(rS2) > 0:
            self.results["Change"] = self.cp2 - self.cp1
            self.plots_S1.unhide()
            self.plots_S2.unhide()
        
    #***************************load_operations()***************************
    def load_operations(self):
        '''
        
        Args: 
        Returns:
        Raises:
        '''
        self.ops = Operations(self)
        self.vert_headers = ["S1", "S2", "Change", "Goal"]
        self.horiz_headers = self.ops.get_ops("table").keys()
        self.horiz_headers.sort()
        
    #***************************compute_operations()***************************
    def compute_operations(self, cp):
        '''
        
        Args: 
        Returns:
        Raises:
        '''  
        return self.ops.compute(cp)
    
    #***************************change_view()***************************
    def change_view(self, view):
        '''
        
        Args: 
        Returns:
        Raises:
        '''
        self.view_mode = view
        
        temp = []
        temp_plots = []

        if self.view_mode == "R":
            temp = self.ops.get_ops("table").keys()
            temp_plots = self.ops.get_ops("plot").keys()
        
        if self.view_mode == "T":
            for opname, op in self.ops.get_ops("table").items():
                if op.therapist is True or op.patient is True:
                    temp.append(opname)
            
            for opname, op in self.ops.get_ops("plot").items():
                if op.therapist is True or op.patient is True:
                    temp_plots.append(opname)
        
        if self.view_mode == "P":
            for opname, op in self.ops.get_ops("table").items():
                if op.patient is True:
                    temp.append(opname)
                    
            for opname, op in self.ops.get_ops("plot").items():
                if op.patient is True:
                    temp_plots.append(opname)
                    
        self.plots_S1.change_view(temp_plots)
        self.plots_S2.change_view(temp_plots)
        
        temp.sort()
        self.horiz_headers = temp
            
        self.emit(qt4.SIGNAL("sigModified"))
        
    #***************************get_result_at()***************************
    def get_result_at(self, row, col):
        '''
        
        Args: 
        Returns:
        Raises:
        '''
        cpname = self.vert_headers[col]
        cp_results = self.results[cpname]
        
        if len(cp_results) == 0:
            return None
        
        opname = self.horiz_headers[row]
        
        if self.view_mode == "R":
            return cp_results[opname]
        
        if self.view_mode == "T":
            op = self.ops.ops[opname]
            if op.therapist is True or op.patient is True:
                return cp_results[opname]
        
        if self.view_mode == "P":
            op = self.ops.ops[opname]
            if op.patient is True:
                return cp_results[opname]
            
    #***************************get_description_at()***************************
    def get_description_at(self, row, col):
        '''
        
        Args: 
        Returns:
        Raises:
        '''
        cpname = self.vert_headers[col]
        opname = self.horiz_headers[row]
        
        return self.ops.get_description(opname)

    #***************************get_vert_headers()***************************
    def get_vert_headers(self):
        '''
        
        Args: 
        Returns:
        Raises:
        '''
        return self.vert_headers
        
    #***************************get_horiz_headers()***************************
    def get_horiz_headers(self):
        '''
        
        Args: 
        Returns:
        Raises:
        '''
        return self.horiz_headers
        
Example #16
0
# -*- coding: utf-8 -*-

# PyCollisionSim  - A graphical collision simulator wirtten in python
# Copyright (C) 2009 Gregory Haynes <[email protected]>
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.

import sys
from PyQt4 import QtGui
from ui import MainWindow

if __name__ == "__main__":
	app = QtGui.QApplication(sys.argv)
	window = MainWindow()
	window.show()
	sys.exit(app.exec_())