Пример #1
0
def main() -> None:
    app = QtWidgets.QApplication(sys.argv)
    app.setWindowIcon(QtGui.QIcon(resource_path("icon.ico")))
    gui = MainWindow(Const.windowName)
    gui.show()

    app.exec_()
Пример #2
0
def launch():
    os.chdir(os.path.dirname(os.path.realpath(__file__)))
    app = QApplication(sys.argv)
    mw = MainWindow()
    mw.show()
    QTimer.singleShot(0,  lambda: mw.start())
    app.exec_()
Пример #3
0
 def __init__(self, addr, port):
     self.addr = addr
     self.port = port
     self.sckt = socket(AF_INET, SOCK_STREAM)
     self.queue = Queue()
     self.added_queue = Queue()
     self.sended_queue = Queue()
     self.deleted_queue = Queue()
     self.created_queue = Queue()
     self.sended = False
     self.main_window = MainWindow()
     self.receive = Receive(self)
     self.processing = Processing(self)
     self.receive.mysignal_recv.connect(self.show,
                                        QtCore.Qt.QueuedConnection)
     self.processing.mysignal_invite.connect(self.send_agreement,
                                             QtCore.Qt.QueuedConnection)
     self.contact_model = QtGui.QStandardItemModel()
     self.message_model = QtGui.QStandardItemModel()
     # self.processing.mysignal_contact.connect(self.model_add, QtCore.Qt.QueuedConnection)
     self.processing.mysignal_message.connect(self.message,
                                              QtCore.Qt.QueuedConnection)
     self.main_window.ui.pushButton_2.clicked.connect(self.add_contact)
     self.main_window.ui.pushButton.clicked.connect(self.send_message)
     self.contact = None
     # self.processing.mysignal_history.connect(self.add_history, QtCore.Qt.QueuedConnection)
     # self.message_list = []
     # self.message_model.setStringList(self.message_list)
     # self.send_mute = QtCore.QMutex
     self.chat_model = QtGui.QStandardItemModel()
     self.main_window.ui.listView_2.clicked.connect(self.select_contact)
     self.main_window.ui.listView_2.customContextMenuRequested.connect(
         self.context_menu)
     self.delete_action = QtWidgets.QAction(self.main_window.tr('Удалить'),
                                            self.main_window)
     self.delete_action.triggered.connect(self.del_action)
     self.create_chat_action = QtWidgets.QAction(
         self.main_window.tr('Создать групповую беседу'), self.main_window)
     self.create_chat_action.triggered.connect(self.create_chat)
     self.main_window.ui.listView_3.setModel(self.chat_model)
     self.main_window.ui.listView_3.setWordWrap(True)
     self.main_window.ui.listView_3.customContextMenuRequested.connect(
         self.second_context_menu)
     self.invite_action = QtWidgets.QAction(
         self.main_window.tr('Пригласить в чат'), self.main_window)
     self.invite_action.triggered.connect(self.invite_chat)
     self.leave_action = QtWidgets.QAction(
         self.main_window.tr('Покинуть чат'), self.main_window)
     self.leave_action.triggered.connect(self.leave_chat)
     self.listik = NotMainWindow()
     self.listik.ui.listView_2.setModel(self.contact_model)
     # self.listik.setWindowModality(QtCore.Qt.ApplicationModal)
     self.contact_for_invite = None
     self.listik.ui.pushButton.clicked.connect(self.button_invite)
     self.listik.hide()
     self.chat_name = None
     self.processing.mysignal_users.connect(self.add_chat)
     self.main_window.ui.listView_3.clicked.connect(self.select_chat)
Пример #4
0
 def __init__(self):
     self.lesson = None
     self.practice = None
     self.cfg = config.Config()
     self.cfg.create_default_user_config()
     self.factory = OperationFactory()
     MainWindow.__init__(self, self.factory)
     self.new_lesson()
     self.mainloop()
Пример #5
0
 def __init__(self):
     self.lesson = None
     self.practice = None
     self.cfg = config.Config()
     self.cfg.create_default_user_config()
     self.factory = OperationFactory()
     MainWindow.__init__(self, self.factory)
     self.new_lesson()
     self.mainloop()
Пример #6
0
def main():
    file = 'interface_setup.txt'
    this_file = inspect.getfile(inspect.currentframe())
    this_folder = os.path.dirname(os.path.abspath(this_file))
    setup = setupFile()
    data = readJson()
    graphe = Graph()
    setup.read(this_folder + os.sep + file)
    setup._colorframe = '#4f81bd'
    root.configure(bg=setup._colorframe)
    MainWindow(root, setup, graphe)
    root.mainloop()
Пример #7
0
from PyQt5 import QtWidgets as qtW
from GUI import MainWindow
import sys

if __name__ == '__main__':
    try:
        import qdarkstyle as qd
    except ModuleNotFoundError:
        qd = None

    app = qtW.QApplication(sys.argv)
    if qd is not None:
        app.setStyleSheet(qd.load_stylesheet_pyqt5())

    ex = MainWindow()

    ex.show()
    sys.exit(app.exec_())
from GUI import MainWindow

if __name__ == "__main__":
    test = MainWindow()
    test.mainloop()
Пример #9
0
from PyQt5.QtWidgets import QApplication
import sys
from GUI import MainWindow

if __name__ == '__main__':
    app = QApplication([])

    mw = MainWindow()

    sys.exit(app.exec())
Пример #10
0
3D printer error detection application.
This is the main entry for the application.
This application is part of a bachelor thesis project
at NTNU Ålesund Department of ICT and Natural Sciences.
Developed and written by Tomas Paulsen.

RUN:    On Raspberry pi set "useRPI" flag to True
        On PC set "useRPI" flag to False
        Run main.py to start

Usage:  On Raspberry pi a physical button should be used to trigger gathering of images.
        On PC a key button is used to trigger gathering of images.

        Start camera page.
        Apply mask.
        Set HSV threshold values and morphological operations.
        Apply Save Masked Images.

        Start monitoring 3D print.

        The application alert if error is detected.
"""
from GUI import MainWindow
from facade import Facade


useRPi = True
facade = Facade(useRPi=useRPi)
GUIApplication = MainWindow(facade=facade)
GUIApplication.start()
Пример #11
0
class Client:
    def __init__(self, addr, port):
        self.addr = addr
        self.port = port
        self.sckt = socket(AF_INET, SOCK_STREAM)
        self.queue = Queue()
        self.added_queue = Queue()
        self.sended_queue = Queue()
        self.deleted_queue = Queue()
        self.created_queue = Queue()
        self.sended = False
        self.main_window = MainWindow()
        self.receive = Receive(self)
        self.processing = Processing(self)
        self.receive.mysignal_recv.connect(self.show,
                                           QtCore.Qt.QueuedConnection)
        self.processing.mysignal_invite.connect(self.send_agreement,
                                                QtCore.Qt.QueuedConnection)
        self.contact_model = QtGui.QStandardItemModel()
        self.message_model = QtGui.QStandardItemModel()
        # self.processing.mysignal_contact.connect(self.model_add, QtCore.Qt.QueuedConnection)
        self.processing.mysignal_message.connect(self.message,
                                                 QtCore.Qt.QueuedConnection)
        self.main_window.ui.pushButton_2.clicked.connect(self.add_contact)
        self.main_window.ui.pushButton.clicked.connect(self.send_message)
        self.contact = None
        # self.processing.mysignal_history.connect(self.add_history, QtCore.Qt.QueuedConnection)
        # self.message_list = []
        # self.message_model.setStringList(self.message_list)
        # self.send_mute = QtCore.QMutex
        self.chat_model = QtGui.QStandardItemModel()
        self.main_window.ui.listView_2.clicked.connect(self.select_contact)
        self.main_window.ui.listView_2.customContextMenuRequested.connect(
            self.context_menu)
        self.delete_action = QtWidgets.QAction(self.main_window.tr('Удалить'),
                                               self.main_window)
        self.delete_action.triggered.connect(self.del_action)
        self.create_chat_action = QtWidgets.QAction(
            self.main_window.tr('Создать групповую беседу'), self.main_window)
        self.create_chat_action.triggered.connect(self.create_chat)
        self.main_window.ui.listView_3.setModel(self.chat_model)
        self.main_window.ui.listView_3.setWordWrap(True)
        self.main_window.ui.listView_3.customContextMenuRequested.connect(
            self.second_context_menu)
        self.invite_action = QtWidgets.QAction(
            self.main_window.tr('Пригласить в чат'), self.main_window)
        self.invite_action.triggered.connect(self.invite_chat)
        self.leave_action = QtWidgets.QAction(
            self.main_window.tr('Покинуть чат'), self.main_window)
        self.leave_action.triggered.connect(self.leave_chat)
        self.listik = NotMainWindow()
        self.listik.ui.listView_2.setModel(self.contact_model)
        # self.listik.setWindowModality(QtCore.Qt.ApplicationModal)
        self.contact_for_invite = None
        self.listik.ui.pushButton.clicked.connect(self.button_invite)
        self.listik.hide()
        self.chat_name = None
        self.processing.mysignal_users.connect(self.add_chat)
        self.main_window.ui.listView_3.clicked.connect(self.select_chat)

    def button_invite(self):
        self.listik.hide()
        contact = self.listik.ui.listView_2.selectedIndexes()[0]
        self.contact_for_invite = self.contact_model.data(contact)
        self.sckt.send(
            JIMInviteChat(self.user_name, self.contact_for_invite,
                          self.chat_name).packing())

    def context_menu(self, pos):
        menu = QtWidgets.QMenu(self.main_window)
        menu.addAction(self.delete_action)
        menu.addAction(self.create_chat_action)
        menu.exec_(self.main_window.ui.listView_2.mapToGlobal(pos))

    def second_context_menu(self, pos):
        menu = QtWidgets.QMenu(self.main_window)
        menu.addAction(self.invite_action)
        menu.addAction(self.leave_action)
        menu.exec_(self.main_window.ui.listView_3.mapToGlobal(pos))

    def leave_chat(self):
        pass

    def invite_chat(self):
        chat = self.main_window.ui.listView_3.selectedIndexes()[0]
        row = chat.row()
        self.chat_name = self.chat_model.data(chat, role=33)
        self.listik.show()

    def del_action(self):
        contact = self.main_window.ui.listView_2.selectedIndexes()[0]
        row = contact.row()
        self.contact = self.contact_model.data(contact)
        print(self.contact)
        msg = JIMDelContact(self.user_name, self.contact)
        self.sckt.send(msg.packing())
        resp = self.deleted_queue.get()
        if resp == "DELETED":
            self.db.del_messages(self.contact)
            self.db.del_contact(msg.contact)
            self.contact_model.removeRow(row)

        else:
            print('Как это!?!')

    def name(self):
        name, ok = QtWidgets.QInputDialog.getText(self.main_window, 'СКУПЕ',
                                                  'Введите имя')
        if ok:
            self.user_name = name
            self.db = ClientDB(self.user_name)

    def send_agreement(self, contact, room):
        print('invited!!!')
        dialog = QtWidgets.QMessageBox.question(
            self.main_window,
            'СКУРЕ',
            '{} хочет добавить вас в групповую беседу'.format(contact),
        )
        # print(dialog)
        # print(type(dialog))
        if dialog == 16384:
            print('Yes')
            msg = JIMResponse(INVITED, room)
            self.sckt.send(msg.packing())
            icon = 'chat.png'
            chat_item = QtGui.QStandardItem(QtGui.QIcon(icon), '*')
            chat_item.setData(room, role=33)
            self.chat_model.appendRow(chat_item)
            self.db.add_contact(room, room)
            self.sckt.send(JIMGetUsers(self.user_name, room).packing())
        elif dialog == 65536:
            print('No')

    def add_contact(self):
        contact = self.main_window.ui.lineEdit_2.text()
        msg = JIMAddContact(self.user_name, contact).packing()
        self.sckt.send(msg)
        print('before resp')
        resp = self.added_queue.get()
        print('after resp')
        if resp == 'ADDED':
            id = self.added_queue.get()
            self.db.add_contact(contact, contact, id)
            self.model_add(contact)
        elif resp == 'NOPE!':
            pass

    def vk(self, contact):
        self.contact = contact

    def select_chat(self, contact):
        self.message_model.clear()
        print(contact)
        name = self.chat_model.data(contact, role=33)
        print(name)
        self.contact = name
        self.get_good_messages()
        self.main_window.ui.listView.setModel(self.message_model)

    def select_contact(self, contact):
        self.message_model.clear()
        print(contact)
        print('123')
        name = self.contact_model.data(contact)
        self.contact = name
        print(self.contact)
        # id = self.db.select_user_id('timmy')
        # print(id)
        # id = self.db.select_user_id(self.receiver)
        self.get_good_messages()
        self.main_window.ui.listView.setModel(self.message_model)
        # lst = []
        # lst.extend(messages)
        # print(lst)
        # self.message_model.setStringList(lst)

        # pass

    def combo_vombo(self, contact):
        pass
        # if self.Right:
        #     print('Right click')
        # else:
        #     print('Left click')

    def message(self, sender, receiver, message, time, receiv):
        if receiver.startswith('<server_chat.Chat object at'):
            new_message = sender + ': ' + message
            self.db.add_mesage(receiver, new_message, time, receiv)
        else:
            self.db.add_mesage(sender, message, time, receiv)
        # pass

    def get_contacts(self):
        msg = JIMGetContacts(self.user_name).packing()
        self.sckt.send(msg)
        msg = self.sckt.recv(MESSAGE_SIZE)
        msg = JIM.unpacking(msg)
        if msg.code == ACCEPTED:
            for _ in range(msg.quantity):
                msg = self.sckt.recv(MESSAGE_SIZE)
                msg = JIM.unpacking(msg)
                self.db.add_contact(msg.user_name, msg.user_nickname,
                                    msg.user_id)
        else:
            self.show(msg)

    # def get_cont_db(self):
    #     self.db.get_contacts()

    def create_chat(self):
        contact = self.main_window.ui.listView_2.selectedIndexes()[0]
        row = contact.row()
        self.contact = self.contact_model.data(contact)
        msg = JIMCreateChat(self.user_name)
        self.sckt.send(msg.packing())
        resp = self.created_queue.get()
        if resp == 'CREATED':
            chat_name = self.created_queue.get()
            print('create_chat: chat_name: {}'.format(chat_name))
            icon = 'chat.png'
            chat_item = QtGui.QStandardItem(QtGui.QIcon(icon), '*')
            chat_item.setData(chat_name, role=33)
            print(1)
            self.db.add_contact(chat_name, chat_name)
            print(2)
            self.chat_model.appendRow(chat_item)
            self.sckt.send(
                JIMInviteChat(self.user_name, self.contact,
                              chat_name).packing())

    def add_chat(self, room, user):
        print('add_chat user: '******'add_chat room: ' + room)
        if isinstance(user, int):
            new_user = self.db.select_user_name(user)
        else:
            new_user = user
        print(new_user)
        chats = self.get_all_items(self.chat_model)
        my_chat = None
        for chat in chats:
            if chat.data(33) == room:
                my_chat = chat
                break
        # item = QtGui.QStandardItem(user)
        # my_chat.appendRow(item)
        users = my_chat.text()
        print('users of my_chat: ' + users)
        print('new_user for my_chat' + new_user)
        if users == '*':
            my_chat.setText(new_user)
        else:
            new_users = users + '\n' + new_user
            my_chat.setText(new_users)
        # for ch in self.chat_model:
        #     print(ch)
        # item = QtGui.QStandardItem(user)
        # chat.appendRow(item)

    def join_chat(self, room):
        msg = JIMJoinChat(self.user_name, room).packing()
        self.sckt.send(msg)

    def get_all_items(self, model):
        count = 0
        lst = []
        while True:
            print(model.item(count))
            if model.item(count):
                lst.append(model.item(count))
                count += 1
            else:
                break
        return lst

    # def leave_chat(self, room):
    #     msg = JIMLeaveChat(self.user_name, room).packing()
    #     self.sckt.send(msg)

    def send_message(self):
        message = self.main_window.ui.lineEdit.text()
        msg = JIMMessage(self.user_name, self.contact, message)
        self.sckt.send(msg.packing())
        resp = self.sended_queue.get()
        if resp == 'SENDED':
            self.add_message(msg.receiver, msg.message, msg.time, False)
            # print('SENDED')
            # self.db.add_mesage(msg.receiver, msg.message, msg.time, False)
            # print('db.add_message()')
            # good_time = time.localtime(msg.time)
            # print('good_time()')
            # result_time = time.strftime('%d%b%H%M%S', good_time)
            # print('result_time')
            # lst = self.message_model.stringList()
            # print('model list')
            # lst.append(result_time)
            # print('append time')
            # lst.append(msg.message)
            # print('apend msg')
        elif resp == 'NOPE!':
            pass

    def add_message(self, receiver, message, msgtime, not_sender):
        print('SENDED')
        self.db.add_mesage(receiver, message, msgtime, not_sender)
        print('db.add_message()')
        good_time = time.localtime(msgtime)
        print('good_time()')
        result_time = time.strftime('%d %b %H:%M:%S', good_time)
        # result_time = '{} {} {} {} {}'.format(good_time[2], good_time[1], good_time[3], good_time[4], good_time[5])
        item = QtGui.QStandardItem()
        item.setText(result_time)
        item.setSelectable(False)
        item.setEditable(False)
        if not_sender:
            item.setTextAlignment(QtCore.Qt.AlignLeft)
            item.setBackground(QtGui.QColor('#E4FDF2'))
        else:
            item.setTextAlignment(QtCore.Qt.AlignRight)
            item.setBackground(QtGui.QColor('#C5F3FF'))
        self.message_model.appendRow(item)
        item = QtGui.QStandardItem()
        item.setText(message)
        item.setSelectable(False)
        item.setEditable(False)
        if not_sender:
            item.setTextAlignment(QtCore.Qt.AlignLeft)
            item.setBackground(QtGui.QColor('#E4FDF2'))
        else:
            item.setTextAlignment(QtCore.Qt.AlignRight)
            item.setBackground(QtGui.QColor('#C5F3FF'))
        self.message_model.appendRow(item)
        # print('result_time')
        # lst = self.message_model.stringList()
        # print('model list')
        # lst.append(result_time)
        # print('append time')
        # lst.append(message)
        # print('apend msg')
        # self.message_model.setStringList(lst)

    # def processing(self):
    #     pass
    # self.get_contacts()
    # resp = self.queue.get()
    # if resp == 'OK':
    #     self.get_contacts()

    # elif isinstance(response, JIMContactList)

    def send_presence(self, user_name):
        msg = JIMPresence(user_name).packing()
        self.sckt.send(msg)

    def dialog_ok(self):
        self.user_name = self.dialog.ui.lineEdit.text()

    def model_add(self, contact):
        print('Model_add')
        # self.db.add_contact(id, contact, contact)
        icon = 'Icon.png'
        item = QtGui.QStandardItem(QtGui.QIcon(icon), contact)
        self.contact_model.appendRow(item)
        self.contact_model.sort(QtCore.Qt.AscendingOrder)

        # index = self.model.indexFromItem(item)
        # print(index)

    def gui_contacts(self):
        lst = self.db.get_contacts()
        for contact in lst:
            icon = 'Icon.png'
            item = QtGui.QStandardItem(QtGui.QIcon(icon), contact.name)
            self.contact_model.appendRow(item)
        self.main_window.ui.listView_2.setModel(self.contact_model)
        self.contact_model.sort(QtCore.Qt.AscendingOrder)

    def get_good_messages(self):
        messages = self.db.get_messages(self.contact)
        messages.sort(key=self.sort_by_time)
        # all_messages = []
        # all_messages.extend(messages)
        # all_messages.extend(my_messages)
        # all_messages.sort(key=self.sort_by_time)
        result = []
        # print(all_messages)
        for message in messages:
            print(message)
            good_time = time.localtime(message.time)
            result_time = time.strftime('%d %b %H:%M:%S', good_time)
            # result_time = '{} {} {} {} {}'.format(good_time[2], good_time[1], good_time[3], good_time[4], good_time[5])
            # result.append(result_time)
            # result.append(message.message)
            item = QtGui.QStandardItem()
            item.setText(result_time)
            item.setSelectable(False)
            item.setEditable(False)
            if not message.receiver:
                item.setTextAlignment(QtCore.Qt.AlignRight)
                item.setBackground(QtGui.QColor('#C5F3FF'))
                self.message_model.appendRow(item)
                item = QtGui.QStandardItem()
                item.setText(message.message)
                item.setTextAlignment(QtCore.Qt.AlignRight)
                item.setSelectable(False)
                item.setEditable(False)
                item.setBackground(QtGui.QColor('#C5F3FF'))
                self.message_model.appendRow(item)
            else:
                # print(message)
                # good_time = time.localtime(message.time)
                # result_time = time.strftime('%d %b %H:%M:%S', good_time)
                # result_time = '{} {} {} {} {}'.format(good_time[2], good_time[1], good_time[3], good_time[4], good_time[5])
                # result.append(result_time)
                # result.append(message.message)
                item = QtGui.QStandardItem()
                item.setText(result_time)
                item.setTextAlignment(QtCore.Qt.AlignLeft)
                item.setSelectable(False)
                item.setEditable(False)
                item.setBackground(QtGui.QColor('#E4FDF2'))
                self.message_model.appendRow(item)
                item = QtGui.QStandardItem()
                item.setText(message.message)
                item.setTextAlignment(QtCore.Qt.AlignLeft)
                item.setSelectable(False)
                item.setEditable(False)
                item.setBackground(QtGui.QColor('#E4FDF2'))
                self.message_model.appendRow(item)
        # return result
        # pass

    def sort_by_time(self, message):
        return message.time

    def go(self):
        self.name()
        self.main_window.setWindowTitle(self.user_name)
        self.main_window.show()
        self.sckt.connect((self.addr, self.port))
        self.send_presence(self.user_name)
        msg = self.sckt.recv(MESSAGE_SIZE)
        msg = JIM.unpacking(msg)
        self.show(msg)
        # resp = self.queue.get()
        # if resp == 'OK':
        self.db.start()
        self.db.clear_chats()
        #     self.get_contacts()
        self.get_contacts()
        # self.queue.put(JIMResponse(OK))
        self.gui_contacts()
        self.receive.start()
        self.processing.start()
        # t1 = Thread(target=self.processing)
        # t1.start()
        # t2 = Thread(target=self.receive)
        # t2.start()

    def stop(self):
        self.sckt.close()

    def show(self, some_data):
        if isinstance(some_data, JIMResponse):
            if some_data.message and some_data.code != CREATED and some_data.code != INVITED\
                    and some_data.code != ACCEPT:
                # print(some_data.message)
                QtWidgets.QMessageBox.information(
                    self.main_window, 'СКУРЕ', '{}'.format(some_data.message))
            elif some_data.code == INVITED:
                print(some_data)
                room = some_data.message
                print(some_data.quantity)
                name = self.db.select_user_name(some_data.quantity)
                print('Name = ' + name)
                QtWidgets.QMessageBox.information(
                    self.main_window, 'СКУРЕ',
                    '{} присоединился к чату'.format(name))
                self.add_chat(room, name)
Пример #12
0
"""

from docopt import docopt
from PIL import Image
from MTCore import MTCore

if __name__ == '__main__':
    argv = docopt(__doc__, version='1.4')
    # print(argv)

    kwargs = {}

    if argv['--gui']:
        from GUI import MainWindow
        MainWindow.vp_start_gui()
    else:
        whiteImg = Image.open(argv['WHITEIMG'])
        blackImg = Image.open(argv['BLACKIMG'])

        if argv['--scale']:
            whiteScale, blackScale = argv['--scale'].split('-')
            whiteImg = whiteImg.resize(
                (round(x * float(whiteScale)) for x in whiteImg.size),
                Image.ANTIALIAS)
            blackImg = blackImg.resize(
                (round(x * float(blackScale)) for x in blackImg.size),
                Image.ANTIALIAS)
        if argv['--light']:
            light = argv['--light'].split('-')
            kwargs['whiteLight'] = float(light[0])
Пример #13
0
        #raise NotImplementedError("gui isnt fonctionnal with session yet")

        import qdarkstyle
        from PyQt5 import QtGui
        from PyQt5.QtWidgets import QApplication
        from GUI import MainWindow

        if "local" in args.session:
            from core import Local_session as Session
        else:
            from core import Live_session as Session

        app = QApplication(sys.argv)
        app.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5())
        launch = MainWindow(
            Session(mode=args.mode,
                    config=args.config,
                    contract_type='classic'))
        launch.show()
        sys.exit(app.exec_())

    elif args.build:
        from core import Local_session as Session
        args.build = "PPO"
        session = Session(mode=args.mode,
                          config=args.config,
                          contract_type='classic',
                          agent=args.build)
        session._stop()

    else:
        if "local" in args.session:
#!/usr/bin/env python
# coding: utf-8

import sys

from PyQt5.QtWidgets import QApplication
from GUI import MainWindow

if __name__ == '__main__':

    app = QApplication(sys.argv)

    mainWin = MainWindow()
    mainWin.resize(400, 300)
    mainWin.setWindowTitle('Simple')
    mainWin.show()

    status = app.exec()
    sys.exit(status)
Пример #15
0
from PyQt4 import QtCore
from PyQt4.QtGui import QApplication
import sys

from GUI import MainWindow

if __name__ == '__main__':

    application = QApplication(sys.argv)
    window = MainWindow()
    window.show()
    sys.exit(application.exec_())
Пример #16
0
from servos import Servo
from TeraRanger_Evo_UART import TeraRanger


def updateParams(servo, window):
    servo.amp = window.AMP
    servo.min = window.OFF
    servo.bpm = window.BPM
    servo.func = servo.switch(window.FUNC)


if __name__ == '__main__':
    servo = Servo("/dev/cu.usbserial-14130")
    # evo = TeraRanger()
    root = tk.Tk()
    Window = MainWindow(root)

    # Main Loop
    while (Window.ExitFlag):
        if Window.update:
            if Window.running:
                updateParams(servo, Window)
            else:
                servo.min = 0  #21 duty cycle corresponds with 0 location

            # Reset the needed parameters
            servo.reset()
            # evo.reset()
            Window.update = 0

        elif Window.running:
import sys
#from MyAlgorithm import MyAlgorithm
from sensors import Sensor
#from sensors.threadSensor import ThreadSensor
#from gui.threadGUI import ThreadGUI
from GUI import MainWindow
from PyQt4 import QtGui

import signal

signal.signal(signal.SIGINT, signal.SIG_DFL)

if __name__ == '__main__':
	sensor = Sensor()
	app = QtGui.QApplication(sys.argv)
	frame = MainWindow()
	frame.setSensor(sensor)
	frame.show()
	#algorithm=MyAlgorithm(sensor)
	#t1 = ThreadSensor(sensor,algorithm)  
	#t1.daemon=True
	#t1.start()

	#t2 = ThreadGUI(frame)  
	#t2.daemon=True
	#t2.start()
    
	sys.exit(app.exec_()) 
Пример #18
0
        arg
):  #equivalent of switch case in python. dictionary look up/jump table
    switcher = {
        "|sin|": servo.absolute,
        "sin^2": servo.squared,
        "sin^4": servo.fourth,
        "sin^6": servo.sixth
    }
    return switcher.get(arg, "invalid")


if __name__ == '__main__':
    servo = servofunctions()  #creates object to control robot
    func = servo.absolute  #initializes breathing pattern
    root = tk.Tk()  #creates window for tkinter
    Window = MainWindow(root)  #creates object to control tkinter

    # Main Loop
    while (1):
        if (
                Window.UpdateCheck == 1
        ):  #runs if update or start/stop has been clicked in GUI (or if exiting)
            if Window.running:
                servo.A = Window.AMP  #these all take GUI values and sends them to the pattern calculations in servo
                servo.M = Window.OFF
                servo.freq = Window.BPM
                func = switch(Window.FUNC)
                servo.reset()  #resets the robot to the offset
                Window.UpdateCheck = 0  #stops this branch from running multiple times without user input
            else:  #resets the robot to zero position when stopped or exiting
                servo.M = 21  #21 duty cycle corresponds with 0 location
Пример #19
0
import sys
import cv2
from PyQt5.QtWidgets import QApplication
from GUI import MainWindow

bg_img = cv2.imread("bgPath")

videoFilePath = r"videoPath"

if __name__ == '__main__':
    app = QApplication(sys.argv)
    main_window = MainWindow(bg_img, videoFilePath)
    main_window.show()
    sys.exit(app.exec_())
Пример #20
0
import matplotlib.pyplot as plt

# Custom Libraries
from GUI import MainWindow
from servos import servofunctions

def switch(arg): #equivalent of switch case in python. dictionary look up/jump table
	switcher = { "|sin|":servo.absolute,"sin^2":servo.squared,
		"sin^4":servo.fourth,"sin^6":servo.sixth}
	return switcher.get(arg,"invalid")

if __name__=='__main__':
	servo = servofunctions() #creates object to control robot
	func = servo.absolute #initializes breathing pattern
	root = tk.Tk() #creates window for tkinter
	Window = MainWindow(root) #creates object to control tkinter


	# Main Loop
	while(1): 
		if(Window.UpdateCheck==1): #runs if update or start/stop has been clicked in GUI (or if exiting)
			if Window.running:
				servo.A = Window.AMP #these all take GUI values and sends them to the pattern calculations in servo
				servo.M = Window.OFF
				servo.freq = Window.BPM
				func = switch(Window.FUNC)
				servo.reset() #resets the robot to the offset
				Window.UpdateCheck = 0 #stops this branch from running multiple times without user input
			else: #resets the robot to zero position when stopped or exiting
				servo.M = 21 #21 duty cycle corresponds with 0 location
				servo.reset()
Пример #21
0
from servos import Servo
from TeraRanger_Evo_UART import TeraRanger


def updateParams(servo, window):
    servo.amp = window.AMP
    servo.min = window.OFF
    servo.bpm = window.BPM
    servo.func = servo.switch(window.FUNC)


if __name__ == '__main__':
    # servo = Servo("/dev/cu.usbserial-14130")
    evo = TeraRanger()
    root = tk.Tk()
    Window = MainWindow(root)

    # Main Loop
    while (Window.ExitFlag):
        if Window.update:
            # if Window.running:
            # 	updateParams(servo,Window)
            # else:
            # 	servo.min = 0 #21 duty cycle corresponds with 0 location

            # Reset the needed parameters
            # servo.reset()
            evo.reset()
            Window.update = 0

        elif Window.running:
Пример #22
0
		self.eData = self.eData[-self.length:]

if __name__=='__main__':
	
	
	# Set up manager for sharing data between processes
	BaseManager.register("servoData",ServoData)
	m = BaseManager()
	m.start()
	sData = m.servoData(0)
	
	#servo = Servos()
	#evo = TeraRanger()
	
	root = tk.Tk()
	Window = MainWindow(root)

	s = multiprocessing.Process(target = Servos, args = (sData,))
	s.start()
	
	g = multiprocessing.Process(target = Window.updatePlot, args = (sData,))
	g.start()
	#while(1):
	#	continue
		#print(evo.data,evo.time)
		#print(servo.data)
		
	# Main Loop
	while(1):
		#if Window.UpdateCheck:
		#	if Window.running:
Пример #23
0
        type=int,
        help=
        "Training or eval mode, default is training. Uselfull only without GUI displayed",
        default=0,
        choices=[0, 1])
    args = parser.parse_args()

    if args.GUI == 1:
        import qdarkstyle
        from PyQt5 import QtGui
        from PyQt5.QtWidgets import QApplication
        from GUI import MainWindow

        app = QApplication(sys.argv)
        app.setStyleSheet(qdarkstyle.load_stylesheet_pyqt5())
        launch = MainWindow()
        launch.show()
        sys.exit(app.exec_())

    else:
        from environnement import Environnement
        from core import Local_Worker

        env = Environnement(0)
        if args.mode == 1:
            env.mode = "eval"
        else:
            env.mode = "train"
        worker = Local_Worker(env)
        worker.run(env)
        sys.exit(0)
Пример #24
0
def main():
    app = QApplication([])
    window = MainWindow()
    window.show()
    app.exec()
Пример #25
0
        self.start.setGeometry(QtCore.QRect(492, 360, 61, 28))
        self.start.setStyleSheet("font: 75 10pt \"Arial\";")
        self.start.setObjectName("start")
        self.retranslateUi(self)
        # self.start.clicked.connect(self.getstart)
        QtCore.QMetaObject.connectSlotsByName(self)

    # def getstart(self):
    #     new = contour()
    #     self.close()
    #     new.show2()

    def retranslateUi(self, Form):
        _translate = QtCore.QCoreApplication.translate
        Form.setWindowTitle(_translate("Form", "主界面"))
        self.start.setText(_translate("Form", "start"))

    def close1(self):
        self.close()


if __name__ == '__main__':
    import sys
    app = QtWidgets.QApplication(sys.argv)
    widget = QtWidgets.QWidget()
    ui = Ui_Form()
    new = MainWindow.GUI_mainView()
    ui.show()
    ui.start.clicked.connect(new.show2)
    ui.start.clicked.connect(ui.close1)
    sys.exit(app.exec_())
Пример #26
0
    logging.getLogger('zeroconf').setLevel(log_level)


def get_ip_address(logger=None):
    try:
        gw = netifaces.gateways()['default'][netifaces.AF_INET]
    except KeyError:
        gw = netifaces.gateways()[netifaces.AF_INET][0]
    gw_ip = '.'.join(gw[0].split('.')[:3])
    gw_iface = gw[1]
    addrs = netifaces.ifaddresses(gw_iface)
    addr = addrs[netifaces.AF_INET][0]
    ip = addr['addr']

    if logger is not None:
        logger.info("ip: " + ip + " interface: " + gw_iface)
    return ip, gw_iface


if __name__ == "__main__":
    debug_mode = False
    if len(sys.argv) > 1:
        debug_mode = sys.argv[1:] == ['--debug']
    setup_logging(debug_mode)
    logger = logging.getLogger(__name__)

    local_ip, interface = get_ip_address(logger)

    main_window = MainWindow(ip=local_ip)
    main_window.mainloop()
Пример #27
0
def launch():
    os.chdir(os.path.dirname(os.path.realpath(__file__)))
    app = QApplication(sys.argv)
    mw = MainWindow()
    mw.show()
    sys.exit(app.exec_())