Пример #1
0
	def showinfo(self):
		infoRecord=LabelFrame(self.window,text='Operation Note')
		infoRecord.place(x=485,y=60)

		sl=Scrollbar(infoRecord)
		sl.pack(side='right',fill='y')
		lb=Listbox(infoRecord,height=25,width=60)
		lb.pack()

		lb['yscrollcommand']=sl.set
		sl['command']=lb.yview

		self.lb=lb
Пример #2
0
	def path(self):
		path_frame=LabelFrame(self.window,text='Input paths',width=450,height=100)
		path_frame.place(x=20,y=60)

		ora_mes=Message(path_frame,text='Excel from ORA:',width=120)
		ora_mes.place(x=10,y=0)
		self.ora_entry=Entry(path_frame,textvariable=self.ora_path,width=35)
		self.ora_entry.place(x=130,y=0)
		ora_button=Button(path_frame,text='Select…',command=self.selectPath1)
		ora_button.place(x=365,y=0)

		calcu_mes=Message(path_frame,text='Calculator:',width=120)
		calcu_mes.place(x=10,y=40)
		self.calcu_entry=Entry(path_frame,textvariable=self.calcu_path,width=35)
		self.calcu_entry.place(x=130,y=40)
		calcu_button=Button(path_frame,text='Select…',command=self.selectPath2)
		calcu_button.place(x=365,y=40)
Пример #3
0
class Application(object):
    def __init__(self):
        self.logger = get_logger('dashboard')

        self.server = SocketServer.UDPServer(
            (settings.DASHBOARD_HOST, settings.DASHBOARD_PORT),
            self.handle_request)
        self.server.timeout = settings.DASHBOARD_REQUEST_TIMEOUT

        self.raw_telem_time = 0
        self.raw_telem_bat = 0
        self.raw_telem_temp = 0
        self.raw_telem_photo = 0

        self.__init_main()
        self.__init_motor()
        self.__init_light()
        self.__init_video()
        self.__init_telem()

    def __init_main(self):
        self.window = Tk()
        self.window.wm_minsize(400, 400)

    def __init_motor(self):
        self.w_lf_motor = LabelFrame(self.window, text=u'Моторы')
        self.w_scale_motor1 = Scale(self.w_lf_motor, from_=-255, to=255)
        self.w_scale_motor2 = Scale(self.w_lf_motor, from_=-255, to=255)

        self.w_lf_motor.place(relx=0, rely=0, relwidth=1, relheight=0.3)
        self.w_scale_motor1.place(relx=0, rely=0, relwidth=1, relheight=1)
        self.w_scale_motor2.place(relx=0.5, rely=0, relwidth=1, relheight=1)

    def __init_light(self):
        self.w_lf_light = LabelFrame(self.window, text=u'Свет')
        self.w_l_light = Label(self.w_lf_light,
                               text=u'Выключен',
                               fg='red',
                               font='Arial 20')

        self.w_lf_light.place(relx=0, rely=0.3, relwidth=1, relheight=0.15)
        self.w_l_light.place(relx=0, rely=0, relwidth=1, relheight=1)

    def __init_video(self):
        self.w_lf_video = LabelFrame(self.window, text=u'Видео')
        self.w_l_video = Label(self.w_lf_video,
                               text=u'Выключен',
                               fg='red',
                               font='Arial 20')
        self.w_b_show = Button(self.w_lf_video,
                               text=u'mplayer',
                               command=self.start_mplayer)

        self.w_lf_video.place(relx=0, rely=0.45, relwidth=1, relheight=0.15)
        self.w_l_video.place(relx=0, rely=0, relwidth=0.7, relheight=1)
        self.w_b_show.place(relx=0.7, rely=0, relwidth=0.3, relheight=1)

    def __init_telem(self):
        # телеметрия
        self.w_lf_telem = LabelFrame(self.window, text=u'Телеметрия')
        self.w_l_telem_time = Label(self.w_lf_telem,
                                    text=u'0',
                                    font='Arial 15')
        self.w_l_telem_bat = Label(self.w_lf_telem, text=u'0', font='Arial 15')
        self.w_l_telem_temp = Label(self.w_lf_telem,
                                    text=u'0',
                                    font='Arial 15')
        self.w_l_telem_photo = Label(self.w_lf_telem,
                                     text=u'0',
                                     font='Arial 15')

        self.w_lf_telem.place(relx=0, rely=0.6, relwidth=1, relheight=0.4)

        Label(self.w_lf_telem, text=u'Время:',
              font='Arial 15').place(relx=0,
                                     rely=0,
                                     relwidth=0.5,
                                     relheight=0.25)
        Label(self.w_lf_telem, text=u'Батарея:',
              font='Arial 15').place(relx=0,
                                     rely=0.25,
                                     relwidth=0.5,
                                     relheight=0.25)
        Label(self.w_lf_telem, text=u'Температура:',
              font='Arial 15').place(relx=0,
                                     rely=0.5,
                                     relwidth=0.5,
                                     relheight=0.25)
        Label(self.w_lf_telem, text=u'Освещенность:',
              font='Arial 15').place(relx=0,
                                     rely=0.75,
                                     relwidth=0.5,
                                     relheight=0.25)

        self.w_l_telem_time.place(relx=0.5,
                                  rely=0,
                                  relwidth=0.5,
                                  relheight=0.25)
        self.w_l_telem_bat.place(relx=0.5,
                                 rely=0.25,
                                 relwidth=0.5,
                                 relheight=0.25)
        self.w_l_telem_temp.place(relx=0.5,
                                  rely=0.5,
                                  relwidth=0.5,
                                  relheight=0.25)
        self.w_l_telem_photo.place(relx=0.5,
                                   rely=0.75,
                                   relwidth=0.5,
                                   relheight=0.25)

    def set_motor_value(self, left_value, right_value):
        if left_value > 255:
            left_value = 255
        elif left_value < -255:
            left_value = -255
        self.w_scale_motor1.set(left_value)

        if right_value > 255:
            right_value = 255
        elif right_value < -255:
            right_value = -255
        self.w_scale_motor2.set(right_value)

    def set_light(self, value):
        """
        устанавливает значение для фонарика
        :param value:
        """
        if value == 1:
            self.w_l_light['text'] = u'Включен'
            self.w_l_light['fg'] = 'green'
        else:
            self.w_l_light['text'] = u'Выключен'
            self.w_l_light['fg'] = 'red'

    def set_video(self, value):
        """
        устанавливает значение для фонарика
        :param value:
        """
        if value == 1:
            self.w_l_video['text'] = u'Включен'
            self.w_l_video['fg'] = 'green'
        else:
            self.w_l_video['text'] = u'Выключен'
            self.w_l_video['fg'] = 'red'

    def set_time(self, value):
        """
        устанавливает значение для даты
        :param value:
        """
        if self.raw_telem_time == value:
            return
        self.raw_telem_time = value

        try:
            value = datetime.fromtimestamp(value).strftime('%Y.%m.%d %H:%M:%S')
        except Exception as err:
            print(err)
            self.logger.debug(str(err))

        self.w_l_telem_time['text'] = value

    def set_bat(self, value):
        """
        устанавливает значение для батареи
        :param value:
        """
        if self.raw_telem_bat == value:
            return
        self.raw_telem_bat = value

        self.w_l_telem_bat['text'] = value

    def set_temp(self, value):
        """
        устанавливает значение для температуры
        :param value:
        """
        if self.raw_telem_temp == value:
            return
        self.raw_telem_temp = value

        self.w_l_telem_temp['text'] = '{0} ({1})'.format(
            round((value * 3.3 / 1024 - 0.5) / 0.01, 3), value)

    def set_photo(self, value):
        """
        устанавливает значение для температуры
        :param value:
        """
        if self.raw_telem_photo == value:
            return
        self.raw_telem_photo = value

        self.w_l_telem_photo['text'] = value

    def start_mplayer(self):
        """
        включает mplayer
        """
        process = subprocess.Popen(settings.VIDEO_SHOW_CMD, shell=True)

    def handle_request(self, request, client_address, server):
        """
        обработка входных данных
        :param request:
        :param client_address:
        :param server:
        :return:
        """
        _request, _socket = request

        if ',' not in _request:
            return

        values = [int(i) for i in _request.split(',')]

        self.set_motor_value(*values[:2])
        self.set_light(values[2])
        self.set_video(values[3])
        self.set_time(values[4])
        self.set_temp(values[5])
        self.set_bat(values[6])
        self.set_photo(values[7])

    def wait_request(self):
        """"""
        self.server.handle_request()
        self.register_mainloop()

    def register_mainloop(self):
        """
        регистриуем обработчик, который периодический будет обрабатывать события
        """
        self.window.after(after_timeout, self.wait_request)

    def run(self):
        """"""
        try:
            self.register_mainloop()
            self.window.mainloop()
        except KeyboardInterrupt:
            pass
        except Exception as err:
            self.logger.debug(err)
            import traceback
            self.logger.debug(traceback.format_exc())
            raise
Пример #4
0
class QRReturnMainWindow(Frame):

    def __init__(self, master):
        Frame.__init__(self, master)
        self.serial_num_internal = StringVar()
        self.master = master
        self.results = StringVar()
        self.__initUi()

    #===========================================================================
    # Initialize and reset GUI
    #===========================================================================
    def __initUi(self):
        self.master.title('Shine Production')
        self.pack(fill=BOTH, expand=1)

        Style().configure("TFrame", background="#333")

        #Status of Test frame
        self.status_frame = LabelFrame(self, text='Status', relief=RIDGE, width=800, height=500)
        self.status_frame.place(x=20, y=20)
        
        #QR SERIAL # Frame
        self.path_frame = LabelFrame(self, text='QR Serial Code', relief=RIDGE, height=60, width=235)
        self.path_frame.place(x=400, y=550)
        entry = Entry(self.path_frame, bd=5, textvariable=self.serial_num_internal)
        entry.place(x=50, y=5)

        #TEST RESULTS LABEL
        w = Label(self.status_frame, textvariable=self.results)
        w.place(x=50, y=50)

        #START Button
        self.start_button = Button(self, text="Start", command=self.start, height=4, width=20)
        self.start_button.place(x=100, y=550)

        # Initialize the DUT
        initDUT()

    def start(self):
        self.start_button.config(state=DISABLED)
        self.start_button.update()
        self.results.set("")
        self.__setStatusLabel(2)
        uiText = ""
        self.results.set(uiText)

        self.serial_num_internal.set("S123Z12345")
        serial_num_internal = "S123Z12345"
        # self.serial_num.set("FL11111111")
        # serial_num = "FL11111111"  
        print "Serial number (internal): %s" % serial_num_internal

        # Initialize the Agilent 34461
        instr = A34461(AGILENT_BASE_ADDRESS, AGILENT_SUB_ADDRESS)
        instr.setModeToCurrent()

        results = executeReturnTestSequence(self.serial_num_internal.get(), instr)

        # self.parseResults(results)
        self.__setStatusLabel(results)
        
        self.serial_num_internal.set("")
        self.start_button.config(state=ACTIVE)
        self.start_button.update()

    def parseResults(self, results):
        uiText = ''
        success = 1
        print results
        if results == -1:
            success = 3
            uiText += "Something wrong with connection to source meter."
        else:
            if results[SCAN_FAIL] == 1:
                success = 0
                uiText += "Couldn't find Shine \n"

            if results[CHECK_FW_FAIL] == 1:
                success = 0
                uiText += "Invalid firmware version. \n"
                
            if results[ACCEL_STREAM_FAIL] == 1:
                success = 0
                uiText += "Acceleromete data not correct. \n"

            if results[SN_DEFAULT_FAIL] == 1:
                success = 0
                uiText += "This serial # is 9876543210.\n"

            if results[SN_MISMATCH_FAIL] == 1:
                success = 0
                uiText += "Serial # scanned does not match internal (bt) serial #. \n"

            if results[TIMEOUT_FAIL] == 1:
                success = 0
                uiText += "Bluetooth connection timeout. \n"

            if results[AVG_CURRENT_FAIL] == 1:
                success = 0
                uiText += "Average operating current falls outside accepted range for this firmware. \n"

            if results[SN_DUPLICATE_FAIL] == 1:
                success = 0
                uiText += "This Shine is a duplicate serial number. \n"

            if results[RECENTLY_SYNCED_FAIL] == 1:
                success = 0
                uiText += "A Shine with this SN was synced in the past month. \n"

            if results[BATTERY_PLOT_FAIL] == 1:
                success = 0
                uiText += "Human determined battery plots failed."

            if success:
                uiText = "This Shine is in good condition!\n"

        self.results.set(uiText)
        self.__setStatusLabel(success)

    def __setStatusLabel(self, success):
        if success == 1:
            self.status_frame.config(text='SUCCESS', bg=STATUS_OK_COLOR)
        elif success == 2:
            self.status_frame.config(text='Status', bg='yellow')
        elif success == 3:
            self.status_frame.config(text='Something Wrong', bg='blue')
        else:
            self.status_frame.config(text='FAIL', bg=STATUS_ERROR_COLOR)
        self.update()
Пример #5
0
class _Hatch_GUI(object):
    """
    create a Hatch object from
    hatch_supt and to then create a skeleton python project.
    """
    def __init__(self, master):
        self.initComplete = 0
        self.master = master
        self.x, self.y, self.w, self.h = -1, -1, -1, -1

        # bind master to <Configure> in order to handle any resizing, etc.
        # postpone self.master.bind("<Configure>", self.Master_Configure)
        self.master.bind('<Enter>', self.bindConfigure)

        self.master.title("PyHatch GUI")
        self.master.resizable(0, 0)  # Linux may not respect this

        dialogframe = Frame(master, width=810, height=630)
        dialogframe.pack()

        self.Shortdesc_Labelframe = LabelFrame(
            dialogframe,
            text="Short Description (1-liner)",
            height="90",
            width="718")
        self.Shortdesc_Labelframe.place(x=60, y=127)

        helv20 = tkFont.Font(family='Helvetica', size=20, weight='bold')

        self.Buildproject_Button = Button(dialogframe,
                                          text="Build Project",
                                          width="15",
                                          font=helv20)
        self.Buildproject_Button.place(x=492, y=10, width=263, height=68)
        self.Buildproject_Button.bind("<ButtonRelease-1>",
                                      self.Buildproject_Button_Click)

        self.Selectdir_Button = Button(dialogframe,
                                       text="<Select Directory>",
                                       width="15")
        self.Selectdir_Button.place(x=72, y=585, width=672, height=31)
        self.Selectdir_Button.bind("<ButtonRelease-1>",
                                   self.Selectdir_Button_Click)

        self.Author_Entry = Entry(dialogframe, width="15")
        self.Author_Entry.place(x=228, y=424, width=187, height=21)
        self.Author_Entry_StringVar = StringVar()
        self.Author_Entry.configure(textvariable=self.Author_Entry_StringVar)
        self.Author_Entry_StringVar.set("John Doe")

        self.Classname_Entry = Entry(dialogframe, width="15")
        self.Classname_Entry.place(x=192, y=73, width=165, height=21)
        self.Classname_Entry_StringVar = StringVar()
        self.Classname_Entry.configure(
            textvariable=self.Classname_Entry_StringVar)
        self.Classname_Entry_StringVar.set("MyClass")

        self.Copyright_Entry = Entry(dialogframe, width="15")
        self.Copyright_Entry.place(x=228, y=478, width=461, height=21)
        self.Copyright_Entry_StringVar = StringVar()
        self.Copyright_Entry.configure(
            textvariable=self.Copyright_Entry_StringVar)
        self.Copyright_Entry_StringVar.set("Copyright (c) 2013 John Doe")

        self.Email_Entry = Entry(dialogframe, relief="sunken", width="15")
        self.Email_Entry.place(x=228, y=505, width=458, height=21)
        self.Email_Entry_StringVar = StringVar()
        self.Email_Entry.configure(textvariable=self.Email_Entry_StringVar)
        self.Email_Entry_StringVar.set("*****@*****.**")

        self.GithubUserName_Entry = Entry(dialogframe,
                                          relief="sunken",
                                          width="15")
        self.GithubUserName_Entry.place(x=228, y=539, width=458, height=21)
        self.GithubUserName_Entry_StringVar = StringVar()
        self.GithubUserName_Entry.configure(
            textvariable=self.GithubUserName_Entry_StringVar)
        self.GithubUserName_Entry_StringVar.set("github_user_name")

        self.Funcname_Entry = Entry(dialogframe, width="15")
        self.Funcname_Entry.place(x=192, y=100, width=157, height=21)
        self.Funcname_Entry_StringVar = StringVar()
        self.Funcname_Entry.configure(
            textvariable=self.Funcname_Entry_StringVar)
        self.Funcname_Entry_StringVar.set("my_function")

        # License values should be correct format
        LICENSE_OPTIONS = tuple(sorted(CLASSIFIER_D.keys()))
        self.License_Entry_StringVar = StringVar()
        self.License_Entry = OptionMenu(dialogframe,
                                        self.License_Entry_StringVar,
                                        *LICENSE_OPTIONS)
        self.License_Entry.place(x=552, y=424, width=184, height=21)
        self.License_Entry_StringVar.set(LICENSE_OPTIONS[0])

        self.Mainpyname_Entry = Entry(dialogframe, width="15")
        self.Mainpyname_Entry.place(x=168, y=37, width=196, height=21)
        self.Mainpyname_Entry_StringVar = StringVar()
        self.Mainpyname_Entry.configure(
            textvariable=self.Mainpyname_Entry_StringVar)
        self.Mainpyname_Entry_StringVar.set("main.py")

        self.Projname_Entry = Entry(dialogframe, width="15")
        self.Projname_Entry.place(x=168, y=10, width=194, height=21)
        self.Projname_Entry_StringVar = StringVar()
        self.Projname_Entry.configure(
            textvariable=self.Projname_Entry_StringVar)
        self.Projname_Entry_StringVar.set("MyProject")

        self.Shortdesc_Entry = Entry(dialogframe, width="15")
        self.Shortdesc_Entry.place(x=72, y=150, width=688, height=48)
        self.Shortdesc_Entry_StringVar = StringVar()
        self.Shortdesc_Entry.configure(
            textvariable=self.Shortdesc_Entry_StringVar)
        self.Shortdesc_Entry_StringVar.set("My project does this")

        # Status must be correct format
        self.Status_Entry_StringVar = StringVar()
        self.Status_Entry = OptionMenu(dialogframe,
                                       self.Status_Entry_StringVar,
                                       *DEV_STATUS_OPTIONS)
        self.Status_Entry.place(x=228, y=451, width=183, height=21)
        self.Status_Entry_StringVar.set(DEV_STATUS_OPTIONS[0])

        self.Version_Entry = Entry(dialogframe, width="15")
        self.Version_Entry.place(x=552, y=451, width=184, height=21)
        self.Version_Entry_StringVar = StringVar()
        self.Version_Entry.configure(textvariable=self.Version_Entry_StringVar)
        self.Version_Entry_StringVar.set("0.1.1")

        self.Author_Label = Label(dialogframe, text="Author", width="15")
        self.Author_Label.place(x=96, y=424, width=112, height=22)

        self.Classname_Label = Label(dialogframe,
                                     text="Class Name",
                                     width="15")
        self.Classname_Label.place(x=60, y=73, width=112, height=22)

        self.Copyright_Label = Label(dialogframe, text="Copyright", width="15")
        self.Copyright_Label.place(x=96, y=478, width=113, height=23)

        self.Email_Label = Label(dialogframe, text="Email", width="15")
        self.Email_Label.place(x=96, y=505, width=113, height=23)

        self.GithubUserName_Label = Label(dialogframe,
                                          text="GithubUserName",
                                          width="15")
        self.GithubUserName_Label.place(x=96, y=539, width=113, height=23)

        self.Funcname_Label = Label(dialogframe,
                                    text="Function Name",
                                    width="15")
        self.Funcname_Label.place(x=60, y=100, width=112, height=22)

        self.License_Label = Label(dialogframe, text="License", width="15")
        self.License_Label.place(x=432, y=424, width=113, height=23)

        self.Longdesc_Label = Label(dialogframe,
                                    text="Paragraph Description",
                                    width="15")
        self.Longdesc_Label.place(x=216, y=220, width=376, height=22)

        self.Mainpyname_Label = Label(dialogframe,
                                      text="Main Python File",
                                      width="15")
        self.Mainpyname_Label.place(x=48, y=37, width=112, height=22)

        self.Projname_Label = Label(dialogframe,
                                    text="Project Name",
                                    width="15")
        self.Projname_Label.place(x=48, y=10, width=112, height=22)

        self.Selectdir_Label = Label(
            dialogframe,
            text="Select the Directory Below Which to Place Your Project",
            width="15")
        self.Selectdir_Label.place(x=156, y=567, width=536, height=24)

        self.Status_Label = Label(dialogframe, text="Status", width="15")
        self.Status_Label.place(x=96, y=451, width=114, height=24)

        self.Version_Label = Label(dialogframe, text="Version", width="15")
        self.Version_Label.place(x=432, y=451, width=113, height=23)

        self.Isclass_Radiobutton = Radiobutton(dialogframe,
                                               text="Class Project",
                                               value="Class Project",
                                               width="15",
                                               anchor=W)
        self.Isclass_Radiobutton.place(x=320, y=73, width=135, height=27)
        self.RadioGroup1_StringVar = StringVar()
        self.RadioGroup1_StringVar.set("Class Project")
        self.RadioGroup1_StringVar_traceName = \
            self.RadioGroup1_StringVar.trace_variable("w",
                                                      self.RadioGroup1_StringVar_Callback)
        self.Isclass_Radiobutton.configure(variable=self.RadioGroup1_StringVar)

        self.Isfunction_Radiobutton = Radiobutton(dialogframe,
                                                  text="Function Project",
                                                  value="Function Project",
                                                  width="15",
                                                  anchor=W)
        self.Isfunction_Radiobutton.place(x=320, y=100, width=135, height=27)
        self.Isfunction_Radiobutton.configure(
            variable=self.RadioGroup1_StringVar)

        lbframe = Frame(dialogframe)
        self.Text_1_frame = lbframe
        scrollbar = Scrollbar(lbframe, orient=VERTICAL)
        self.Text_1 = Text(lbframe,
                           width="40",
                           height="6",
                           yscrollcommand=scrollbar.set)
        scrollbar.config(command=self.Text_1.yview)
        scrollbar.pack(side=RIGHT, fill=Y)
        self.Text_1.pack(side=LEFT, fill=BOTH, expand=1)

        self.Text_1_frame.place(x=72, y=250, width=665, height=160)
        # >>>>>>insert any user code below this comment for section "top_of_init"

        self.dirname = '<Select Directory>'
        self.Funcname_Entry.config(state=DISABLED)

        h = Hatch(projName='MyProject', mainDefinesClass='N')
        if h.author:
            self.Author_Entry_StringVar.set(h.author)
        if h.proj_license:
            self.License_Entry_StringVar.set(h.proj_license)
        if h.proj_copyright:
            self.Copyright_Entry_StringVar.set(h.proj_copyright)
        if h.email:
            self.Email_Entry_StringVar.set(h.email)
        if h.github_user_name:
            self.GithubUserName_Entry_StringVar.set(h.github_user_name)
        del h

    def build_result_dict(self):
        """Takes user inputs from GUI and builds a dictionary of results"""
        # pylint: disable=W0201
        self.result = {}  # return a dictionary of results

        self.result["author"] = self.Author_Entry_StringVar.get()
        self.result["status"] = self.Status_Entry_StringVar.get()
        self.result["proj_license"] = self.License_Entry_StringVar.get()
        self.result["version"] = self.Version_Entry_StringVar.get()
        self.result["proj_copyright"] = self.Copyright_Entry_StringVar.get()
        self.result["email"] = self.Email_Entry_StringVar.get()
        self.result[
            "github_user_name"] = self.GithubUserName_Entry_StringVar.get()

        self.result["main_py_name"] = self.Mainpyname_Entry_StringVar.get()
        self.result["proj_name"] = self.Projname_Entry_StringVar.get()
        self.result["class_name"] = self.Classname_Entry_StringVar.get()
        self.result["func_name"] = self.Funcname_Entry_StringVar.get()

        self.result["short_desc"] = self.Shortdesc_Entry_StringVar.get()
        self.result["para_desc"] = self.Text_1.get(1.0, END)
        self.result["parent_dir"] = self.dirname

        if self.RadioGroup1_StringVar.get() == "Class Project":
            self.result["is_class_project"] = 'Y'
        else:
            self.result["is_class_project"] = 'N'

    def Buildproject_Button_Click(self, event):
        """When clicked, this method gathers all the user inputs
            and builds the project skeleton in the directory specified.
        """

        #  tkinter requires arguments, but I don't use them
        # pylint: disable=W0613

        # >>>>>>insert any user code below this comment for section "compID=29"
        # replace, delete, or comment-out the following
        #print "executed method Buildproject_Button_Click"

        if not os.path.isdir(self.dirname):
            ShowError(
                title='Need Parent Directory',
                message=
                'You need to choose a directory in which to place your project.'
            )
        else:
            self.build_result_dict()  # builds self.result dict
            r = self.result

            h = Hatch(projName=r["proj_name"],
                      mainDefinesClass=r["is_class_project"],
                      mainPyFileName=r["main_py_name"],
                      mainClassName=r["class_name"],
                      mainFunctionName=r["func_name"],
                      author=r["author"],
                      proj_copyright=r["proj_copyright"],
                      proj_license=r["proj_license"],
                      version=r["version"],
                      email=r["email"],
                      status=r["status"],
                      github_user_name=r["github_user_name"],
                      simpleDesc=r["short_desc"],
                      longDesc=r["para_desc"])

            call_result = h.save_project_below_this_dir(self.dirname)
            if call_result == 'Success':
                if AskYesNo(title='Exit Dialog',
                            message='Do you want to leave this GUI?'):
                    self.master.destroy()
            else:
                ShowWarning( title='Project Build Error',
                             message='Project did NOT build properly.\n'+\
                            'Warning Message = (%s)'%call_result)

    # return a string containing directory name
    def AskDirectory(self, title='Choose Directory', initialdir="."):
        """Simply wraps the tkinter function of the "same" name."""
        dirname = tkFileDialog.askdirectory(parent=self.master,
                                            initialdir=initialdir,
                                            title=title)
        return dirname  # <-- string

    def Selectdir_Button_Click(self, event):
        #  I don't care what the exception is, if there's a problem, bail
        #     Also, I want to redefine the dirname attribute here
        # pylint: disable=W0702, W0201

        #  tkinter requires arguments, but I don't use them
        # pylint: disable=W0613
        """Selects the directory in which to build project."""

        dirname = self.AskDirectory(title='Choose Directory For Nose Tests',
                                    initialdir='.')
        if dirname:
            try:
                dirname = os.path.abspath(dirname)
            except:
                self.dirname = '<Select Directory>'
                return  # let Alarm force dir selection

            self.dirname = dirname

            self.Selectdir_Button.config(text=self.dirname)

    def RadioGroup1_StringVar_Callback(self, varName, index, mode):
        #  tkinter requires arguments, but I don't use them
        # pylint: disable=W0613
        """Responds to changes in RadioGroup1_StringVar."""
        if self.RadioGroup1_StringVar.get() == "Class Project":
            self.Funcname_Entry.config(state=DISABLED)
            self.Classname_Entry.config(state=NORMAL)
        else:
            self.Classname_Entry.config(state=DISABLED)
            self.Funcname_Entry.config(state=NORMAL)

    # tk_happy generated code. DO NOT EDIT THE FOLLOWING. section "Master_Configure"
    def bindConfigure(self, event):
        """bindConfigure and Master_Configure help stabilize GUI"""
        #  tkinter requires arguments, but I don't use them
        # pylint: disable=W0613
        if not self.initComplete:
            self.master.bind("<Configure>", self.Master_Configure)
            self.initComplete = 1

    def Master_Configure(self, event):
        """bindConfigure and Master_Configure help stabilize GUI"""
        # >>>>>>insert any user code below this comment for section "Master_Configure"
        # replace, delete, or comment-out the following
        if event.widget != self.master:
            if self.w != -1:
                return
        x = int(self.master.winfo_x())
        y = int(self.master.winfo_y())
        w = int(self.master.winfo_width())
        h = int(self.master.winfo_height())
        if (self.x, self.y, self.w, self.h) == (-1, -1, -1, -1):
            self.x, self.y, self.w, self.h = x, y, w, h

        if self.w != w or self.h != h:
            print "Master reconfigured... make resize adjustments"
            self.w = w
            self.h = h
Пример #6
0
class QRMainWindow(Frame):
    def __init__(self, master):
        Frame.__init__(self, master)
        self.serial_num = StringVar()
        self.master = master
        self.__initUi()

    #===========================================================================
    # Initialize and reset GUI
    #===========================================================================
    def __initUi(self):
        self.master.title('Shine Production')
        self.pack(fill=BOTH, expand=1)

        Style().configure("TFrame", background="#333")

        #Status frame
        self.status_frame = LabelFrame(self,
                                       text='Status',
                                       relief=RIDGE,
                                       width=800,
                                       height=500)
        self.status_frame.place(x=20, y=20)

        #QRFrame
        self.path_frame = LabelFrame(self,
                                     text='QR Serial Code',
                                     relief=RIDGE,
                                     height=60,
                                     width=225)
        self.path_frame.place(x=400, y=550)
        entry = Entry(self.path_frame, bd=5, textvariable=self.serial_num)
        entry.place(x=50, y=5)

        #START
        self.start_button = Button(self,
                                   text="Start",
                                   command=self.start,
                                   height=4,
                                   width=20)
        self.start_button.place(x=100, y=550)

    def start(self):
        self.start_button.config(state=DISABLED)
        self.start_button.update()
        self.__setStatusLabel(2)

        success = executeQRSerialSequence(self.serial_num.get())
        self.serial_num.set("")
        self.__setStatusLabel(success)

        self.start_button.config(state=ACTIVE)
        self.start_button.update()

    def __setStatusLabel(self, success):
        if success == 1:
            self.status_frame.config(text='SUCCESS', bg=STATUS_OK_COLOR)
        elif success > 1:
            self.status_frame.config(text='Status', bg='yellow')
        elif success == -1:
            self.status_frame.config(
                text='ERROR CONNECTING TO SOURCE METER. TRY AGAIN.', bg='blue')
        elif success == -2:
            self.status_frame.config(
                text='PC IS NOT CONNECTED TO INTERNET!!!!.', bg='blue')
        else:
            self.status_frame.config(text='FAIL', bg=STATUS_ERROR_COLOR)
        self.update()
Пример #7
0
	def inputinfo(self):
		tabControl=ttk.Notebook(self.window)

		match=ttk.Frame(tabControl,width=450,height=328)
		tabControl.add(match,text=' -Match- ')

		battle=ttk.Frame(tabControl,width=450,height=328)
		tabControl.add(battle,text=' -Fight- ')

		scene=ttk.Frame(tabControl,width=450,height=328)
		tabControl.add(scene,text=' -Round- ')

		tabControl.place(x=20,y=180)

		#Match Info
		num=Message(match,text='Game No.',width=70)
		num.place(x=10,y=10)

		self.num_entry=Entry(match,width=6,textvariable=self.MATCH.gameNum)
		self.num_entry.place(x=80,y=10)


		mapName=Message(match,text='Map:',width=50)
		mapName.place(x=130,y=10)

		self.mapName_cb=ttk.Combobox(match,width=10,textvariable=self.MATCH.mapNum)
		self.mapName_cb['values']=mapList
		self.mapName_cb.place(x=180,y=10)

		time=Message(match,text='Duration:',width=100)
		time.place(x=280,y=10)

		self.time_entry=Entry(match,width=10,textvariable=self.MATCH.gameTime)
		self.time_entry.place(x=350,y=10)

		def selectTeamA(*args):			
			team_selected=teamA_cb.current()
			y=20

			for i in range(0,6):
				self.ap.insert(i,ttk.Combobox(teamA_frame,width=10))
				print self.ap[i]
				self.ap[i]['values']=allPlayers.get(teamList[team_selected],' ')
				name='Player'+str(i+1)
				self.ap[i].insert(0,name)
				self.ap[i].place(x=10,y=y+20*(i+1))
			for i in range(0,6):
				self.ah.insert(i,ttk.Combobox(teamA_frame,width=10))
				self.ah[i]['values']=heroList
				name='hero'
				self.ah[i].insert(0,name)
				self.ah[i].place(x=105,y=y+20*(i+1))
		def selectTeamB(*args):
			team_selected=teamB_cb.current()
			y=20
			for i in range(0,6):
				self.bp.insert(i,ttk.Combobox(teamB_frame,width=10))
				self.bp[i]['values']=allPlayers.get(teamList[team_selected],' ')
				name='Player'+str(i+7)
				self.bp[i].insert(0,name)
				self.bp[i].place(x=10,y=y+20*(i+1))
			for i in range(0,6):
				self.bh.insert(i,ttk.Combobox(teamB_frame,width=10))
				self.bh[i]['values']=heroList
				name='hero'
				self.bh[i].insert(0,name)
				self.bh[i].place(x=105,y=y+20*(i+1))

		#Team A information
		teamA_frame=LabelFrame(match,text='TeamA',width=210,height=200)
		teamA_frame.place(x=10,y=50)

		teamA_name=Message(teamA_frame,text='Name:',width=70)
		teamA_name.place(x=10,y=10)

		teamA_cb=ttk.Combobox(teamA_frame,width=12,textvariable=self.MATCH.teamA)
		teamA_cb['values']=teamList
		teamA_cb.bind('<<ComboboxSelected>>',selectTeamA)
		teamA_cb.place(x=60,y=10)

		#Team B information
		teamB_frame=LabelFrame(match,text='TeamB',width=210,height=200)
		teamB_frame.place(x=230,y=50)

		teamB_name=Message(teamB_frame,text='Name:',width=70)
		teamB_name.place(x=10,y=10)

		teamB_cb=ttk.Combobox(teamB_frame,width=12,textvariable=self.MATCH.teamB)
		teamB_cb['values']=teamList
		teamB_cb.bind('<<ComboboxSelected>>',selectTeamB)
		teamB_cb.place(x=60,y=10)

		self.A=teamA_cb
		self.B=teamB_cb

		winner=Message(match,text='Match Winner:',width=150)
		winner.place(x=10,y=260)
		self.winteam=IntVar()
		if self.MATCH.finalwinner == 'A':
			self.winteam.set(1)
		if self.MATCH.finalwinner == 'B':
			self.winteam.set(2)
		winA=Radiobutton(match,text='TeamA',variable=self.winteam,value=1)
		winB=Radiobutton(match,text='TeamB',variable=self.winteam,value=2)
		winA.place(x=110,y=260)
		winB.place(x=180,y=260)

		attacker=Message(match,text='First Attack:',width=150)
		attacker.place(x=10,y=280)
		
		self.attackteam=IntVar()
		if self.MATCH.attack == 'A':
			self.attackteam.set(1)
		if self.MATCH.attack == 'B':
			self.attackteam.set(2)
		attackA=Radiobutton(match,text='TeamA',variable=self.attackteam,value=1)
		attackB=Radiobutton(match,text='TeamB',variable=self.attackteam,value=2)
		attackA.place(x=110,y=280)
		attackB.place(x=180,y=280)

		matchSave=Button(match,text='Save',width=10,command=self.savematch)
		matchSave.place(x=330,y=290)

		#Battle Info
		battle_label=Label(battle,textvariable=self.BATTLE.caption,width=15,height=1)
		battle_label.place(x=0,y=20)

		start_tag=Label(battle,text='Start time:',foreground='black',width=8,height=1)
		start_tag.place(x=100,y=10)

		self.start_entry=Entry(battle,width=20,textvariable=self.BATTLE.start_time,foreground='black')
		self.start_entry.place(x=200,y=10)

		end_tag=Label(battle,text='End time:',foreground='black',width=8,height=1)
		end_tag.place(x=100,y=40)

		self.end_entry=Entry(battle,width=20,textvariable=self.BATTLE.end_time,foreground='black')
		self.end_entry.place(x=200,y=40)

		#winner
		win_tag=Label(battle,text='Fight Winner:',foreground='black',width=10,height=1) #标签
		win_tag.place(x=100,y=70)

		self.team=IntVar()
		self.team.set(1)
		team1=Radiobutton(battle,text='Team A',variable=self.team,value=1)
		team1.place(x=200,y=70)
		team2=Radiobutton(battle,text='Team B',variable=self.team,value=2)
		team2.place(x=270,y=70)

		next_button=Button(battle,text='Next',width=10,command=self.battlenext)
		next_button.place(x=100,y=100)

		alter_tag=Label(battle,text='Input fight number to alter information:') #标签
		alter_tag.place(x=30,y=150)

		self.alter_entry=Entry(battle,width=5)
		self.alter_entry.place(x=280,y=150)

		alter_button=Button(battle,text='Go',width=7,command=self.fightalter)
		alter_button.place(x=330,y=150)

		battleSave=Button(battle,text='Save',width=10,command=self.savefight)
		battleSave.place(x=330,y=290)

		#Round Info
		round_label=Label(scene,textvariable=self.ROUND.caption,width=15,height=1)
		round_label.place(x=0,y=20)

		sstart_tag=Label(scene,text='Start time:',foreground='black',width=8,height=1)
		sstart_tag.place(x=100,y=10)

		self.sstart_entry=Entry(scene,width=20,textvariable=self.ROUND.start_time,foreground='black')
		self.sstart_entry.place(x=200,y=10)

		send_tag=Label(scene,text='End time:',foreground='black',width=8,height=1)
		send_tag.place(x=100,y=40)

		self.send_entry=Entry(scene,width=20,textvariable=self.ROUND.end_time,foreground='black')
		self.send_entry.place(x=200,y=40)

		snext_button=Button(scene,text='Next',width=10,command=self.roundnext)
		snext_button.place(x=100,y=100)

		salter_tag=Label(scene,text='Input battle number to alter information:') #标签
		salter_tag.place(x=30,y=150)

		self.salter_entry=Entry(scene,width=5)
		self.salter_entry.place(x=280,y=150)

		salter_button=Button(scene,text='Go',width=7,command=self.roundalter)
		salter_button.place(x=330,y=150)

		sceneSave=Button(scene,text='Save',width=10,command=self.saveround)
		sceneSave.place(x=330,y=290)
Пример #8
0
class GuiMainWindow(Frame):
    def __init__(self, master):
        Frame.__init__(self, master)
        self.serial_num = StringVar()
        self.gpioPin = StringVar()
        self.serial_num_smt = StringVar()
        self.master = master
        self.results = StringVar()
        self.debug_mode = BooleanVar()
        self.__initUi()

    #===========================================================================
    # Initialize and reset GUI
    #===========================================================================
    def __initUi(self):
        self.master.title('GPIO Test')
        self.pack(fill=BOTH, expand=1)

        Style().configure("TFrame", background="#333")

        # Status of Test frame
        self.status_frame = LabelFrame(self,
                                       text='Status',
                                       relief=RIDGE,
                                       width=235,
                                       height=100)
        self.status_frame.place(x=20, y=20)

        self.path_frame_1 = LabelFrame(self,
                                       text='GPIO Pin (between 0 and 27)',
                                       relief=RIDGE,
                                       height=60,
                                       width=235)
        self.path_frame_1.place(x=20, y=150)
        self.entry_1 = Entry(self.path_frame_1,
                             bd=5,
                             textvariable=self.gpioPin)
        self.entry_1.place(x=20, y=5)
        self.entry_1.focus_set()

        # TEST RESULTS LABEL
        w = Label(self.status_frame, textvariable=self.results)
        w.place(x=50, y=50)

        # Toggle Button
        self.toggleButton = Button(self,
                                   text="Toggle",
                                   command=self.toggle,
                                   height=4,
                                   width=20,
                                   background='green')
        self.toggleButton.place(x=20, y=250)
        self.toggleButton.bind('<Return>', lambda e: self.hi())

        self.isHi = False
        gpio_ns_init()

    def toggle(self):

        pin = self.entry_1.get()
        if pin == "":
            self.status_frame.config(text="Invalid pin!",
                                     bg=STATUS_ERROR_COLOR)
            return

        validPin = re.match('^[0-9]{1,2}$', pin)

        if not validPin or (int(pin) < 4 or int(pin) > 27):
            self.status_frame.config(text="Invalid pin!",
                                     bg=STATUS_ERROR_COLOR)
            return

        if self.isHi:
            self.status_frame.config(text='Pin is low', bg=STATUS_OK_COLOR)
            self.isHi = False
            self.toggleButton['text'] = "Set Hi"
            gpio_ns_write(int(pin), GPIO_LO)
        else:
            self.isHi = True
            self.status_frame.config(text='Pin is hi', bg=STATUS_OK_COLOR)
            self.toggleButton['text'] = "Set Low"
            gpio_ns_write(int(pin), GPIO_HI)
Пример #9
0
class TwitterSearcher(Frame):
    def __init__(self, parent):
        Frame.__init__(self, parent, background = "white")
        self.keyA = 1
        self.keyB = 1
        self.parent = parent
        self.initUI()
    
    def initUI(self):
        "Text to enter the clear text"
        self.clearLabelFrame = LabelFrame(self.parent, text = "Search Text")
        self.clearLabelFrame.place(x = 65, y = 20)
        self.clearText = Text(self.clearLabelFrame, width = 65, height = 5)
        self.clearText.pack()
        
        "Button to encode"
        self.encodeButton = Button(self.parent, text = "Search", command = self.search)
        self.encodeButton.place(x = 460, y = 130)
        
        "Text to display encoded text"
        self.encodedLabelFrame = LabelFrame(self.parent, text = "Tweets")
        self.encodedLabelFrame.place(x = 65, y = 160)
        self.encodedText = Text(self.encodedLabelFrame, width = 65, height = 15)
        self.encodedText.pack()
        
        "Send tweet"
        self.clearLabelFrame = LabelFrame(self.parent, text = "Tweet")
        self.clearLabelFrame.place(x = 65, y = 400)
        self.sendTweet = Text(self.clearLabelFrame, width = 65, height = 5)
        self.sendTweet.pack()
        
        "Button to encode"
        self.encodeButton = Button(self.parent, text = "Send", command = self.send)
        self.encodeButton.place(x = 470, y = 500)
        
        
    def search(self):
        clear = self.clearText.get(1.0, Tkinter.END)
        rst = Search.search(clear)
        self.encodedText.delete(1.0, Tkinter.END)
        content = Search.jsonParser(rst)
        display = ""
        
        if (len(content) == 0):
            display = "Nothing" 
        else:
            for tweet in content:
                key = tweet.keys()[0]
                display +=  key + " said: \n" + "\t" + tweet.get(key) + "\n\n"
                
            checkReport = False
            for tweet in content:
                if(Search.insertMySQL(tweet)):
                    checkReport = True
            if(checkReport):
                tkMessageBox.showinfo("Insert to database", "Insert successfully" )
        
        self.encodedText.insert(1.0, display)
        
    def send(self):
        message = self.sendTweet.get(1.0, Tkinter.END)
        #print len(message)
        if(142> len(message)>1):
            SendMessage.send(message)
            tkMessageBox.showinfo("Send", "Send successfully")
        else:
            tkMessageBox.showinfo("Send", "No tweet to send, please enter your tweet")