Example #1
0
 def mousePressEvent(self, event):
     if self.flag is True:
         self.flag = False
         self.f1.setPixmap(QPixmap('flagOff.png'))
     print MainConfigure.currentDescriptionItem, self.id
     if MainConfigure.currentDescriptionItem != self.id:
         MainController.textLabelPressed(self.id)
Example #2
0
 def test10_creation(self):
     gui = mock.MagicMock()
     game_factory = mock.MagicMock()
     c = MainController(gui, game_factory)
     self.assertEqual(c.gui, gui)
     self.assertEqual(c.game_factory, game_factory)
     c.gui.show_select_game.assert_not_called()
     c.start()
     c.gui.show_select_game.assert_called_once_with()
Example #3
0
    def mousePressEvent(self, event):
        if isinstance(self.id, int):
            from userleftwidget import userLeftWidget
            userLeftWidget.getInstance().update(self.id)
        elif self.id is 'switch':
            from userleftwidget import userLeftWidget
            uLW = userLeftWidget.getInstance()
            if uLW.currentID == -1:
                return
            from maincontroller import MainController
            MainController.dataClear(uLW.itemSet[uLW.currentID].title)
            from usermanager import userManager
            userManager.getInstance().close()
            #MainController.start()
            #MainController.jobCtl()

        elif self.id is 'delete':
            from userleftwidget import userLeftWidget
            uLW = userLeftWidget.getInstance()
            if uLW.currentID == -1:
                return
            uLW.itemSet[uLW.currentID].setVisible(False)
            from sqlitectl import sqliteCtl
            from mainconfigure import MainConfigure
            sqlwords = [
                "delete from user where id = '{0}'".format(
                    uLW.itemSet[uLW.currentID].title)
            ]
            print sqlwords
            sqliteCtl.updateDB(MainConfigure.userdbPath, *sqlwords)

        elif self.id is 'add':
            from userrightwidget import userRightWidget
            uRW = userRightWidget.getInstance()
            uRW.setVisible(not uRW.isVisible())
            from usermanager import userManager
            uM = userManager.getInstance()
            if uM.width() == 250:
                uM.setWindowTitle('添加用户')
                uM.setFixedWidth(500)
            else:
                uM.setFixedWidth(250)
                uM.setWindowTitle('用户')
Example #4
0
def main():
    app = QApplication()
    #iccstate = IccStateHandler( "ftp.ini")
    setScreenSize(app)
    env = "DEVELOP"
    if not runningInDev():
        # release version running
        terminate_if_running()  # one instance only
        # try:
        #     iccstate.startApplication() # download immo.db from server and set is-in-use flag
        # except Exception as ex:
        #     print( str(ex) )
        #     box = ErrorBox( "ImmoControlCenter", "Failed starting application", str( ex ) )
        #     box.exec_()
        #     return
        createControlFile()  # flag file showing application is running
        env = "RELEASE"
    win = IccMainWindow(env)
    # see: https://stackoverflow.com/questions/53097415/pyside2-connect-close-by-window-x-to-custom-exit-method
    shutDownFilter = ShutDownFilter(win, app)
    win.installEventFilter(shutDownFilter)
    win.show()
    try:
        pos_size = getGeometryOnLastShutdown()
        win.move(pos_size["x"], pos_size["y"])
        #win.resize( pos_size["w"], pos_size["h"] )
        win.setFixedWidth(1100)
        win.setFixedHeight(63)
    except:
        win.resize(1900, 1000)

    MainController(win)

    icon = QIcon("./images/houses.png")
    app.setWindowIcon(icon)

    app.exec_()

    if not runningInDev():
        try:
            # iccstate.stopApplication() # upload immo.db to server and set not-in-use flag
            pass
        except Exception as ex:
            print(str(ex))
            box = ErrorBox("ImmoControlCenter",
                           "Failed shutting down application", str(ex))
            box.exec_()
        finally:
            deleteControlFile()
Example #5
0
class LedControllerServer(BaseHTTPRequestHandler):

    controller = MainController()
    def _set_headers(self):
        self.send_response(200)
        self.send_header('Content-type', 'text/html')
        self.end_headers()

    def do_POST(self):
        self._set_headers()
        self.data_string = self.rfile.read(int(self.headers['Content-Length']))

        print "in post method " + self.data_string

        self.send_response(200)
        self.end_headers()
        self.controller.changeMode(json.loads(self.data_string))
        self.wfile.write("Ok!")
        return
Example #6
0
 def test11_add_and_list_game(self):
     c = MainController(mock.MagicMock(), mock.MagicMock())
     c.add_game('a_name', 'a_type', dict(x=1))
     c.add_game('b_name', 'b_type', dict(x=2))
     self.assertEqual(['a_name', 'b_name'], sorted(c.list_games()))
Example #7
0
def make_mock_controller(names='a b'.split()):
    c = MainController(mock.MagicMock(), make_mock_game_factory())
    for i, name in enumerate(sorted(names)):
        c.add_game(name + '_name', name + '_type', dict(x=i + 1))

    return c.start()
Example #8
0
 def __init__(self):
     self.mainLogic = MainLogic(testing=True, localhost=True, nosynch=True)
     self.mainController = MainController(self.mainLogic)
     self.mainLogic.loadAppdata()
     self.mainLogic.loadConfig()
Example #9
0
from flask import Flask
from flask_cors import CORS
from flask import request
from maincontroller import MainController
import json
import sys

app = Flask(__name__)
CORS(app)
controller = MainController()


def RGBtoBGR(stringRGB):
    result = "\"#"
    result += stringRGB[3:5]
    result += stringRGB[5:7]
    result += stringRGB[1:3]
    result += "\""
    return result


def changeColor(requestData):
    if requestData and "\"color\"" in requestData:
        i = requestData.index("\"color\"")
        newColor = RGBtoBGR(requestData[i + 17:i + 24])
        newData = requestData[:i + 16]
        newData += newColor
        newData += requestData[i + 25:]
        return newData
    else:
        return requestData
Example #10
0
 def mouseReleaseEvent(self, event):
     from maincontroller import MainController
     self.label_.l1.setPixmap(QPixmap('image%s.png' % (self.externalID)))
     MainController.imageButtonPressed(self.externalID)
Example #11
0
import sys
from PyQt5.QtWidgets import QApplication
from maincontroller import MainController

if __name__ == '__main__':
    a = QApplication(sys.argv)
    w = MainController()
    w.start()
    sys.exit(a.exec_())
Example #12
0
            pickle.dump(MainConfigure.currentUser, fp)
        return
        if QMessageBox.question(self, self.tr('Quit'), 'Sure?',
                                QMessageBox.Yes | QMessageBox.No,
                                QMessageBox.No) == QMessageBox.Yes:
            event.accept()
        else:
            event.ignore()


if __name__ == '__main__':
    from maincontroller import MainController
    import sys
    app = QApplication(sys.argv)
    from fileboxctl import fileBoxCtl
    from garbagectl import garbageCtl
    import cPickle as pickle
    import os
    filepath = MainConfigure.currentUserPath
    if os.path.isfile(filepath):
        with open(filepath, 'r') as fp:
            MainConfigure.currentUser = pickle.load(fp)
    garbageCtl.init()

    fileBoxCtl.init()

    MainController.start()

    MainController.jobCtl()
    sys.exit(app.exec_())
Example #13
0
 def mousePressEvent(self, event):
     if MainConfigure.currentManagerItem is not self.externalID - MainConfigure.MAILBOX:
         from maincontroller import MainController
         MainController.imageButtonPressed(self.externalID)