예제 #1
0
def valider ():
    contenu1=e4.get()
    contenu2=e5.get()
    montant=contenu1*contenu2
    if montant<45000:
        montant=montant-((montant*10)/100)
    elif montant<90000:
        montant=montant-((montant*20)/100)
    elif montant<180000:
        montant=montant-((montant*30)/100)
    else:
        montant=montant-((montant*40)/100)
    b.config(command=valider)
    res.config(text='resultat-'+str(montant),fg='blue')
    mbox.showinfo("Information", 'resultat ='+str(montant))
    if IntVar() == 'kalaa' and StringVar() == 'Polo':
      mbox.showinfo('resultat =('votre circuit : 'Kalaa', votre voiture :'Polo')')
    if IntVar() == 'Akouda' and StringVar() == 'Polo':
      mbox.showinfo('resultat =('votre circuit : 'Akouda', votre voiture :'Polo')')
    if IntVar() == 'Sousse' and StringVar() == 'Polo':
       mbox.showinfo('resultat =('votre circuit : 'Sousse', votre voiture :'Polo')')
    if IntVar() == 'Kalaa' and StringVar() == 'Peugeot':
      mbox.showinfo('resultat =('votre circuit : 'kalaa', votre voiture :'Peugeot')')
    if IntVar() == 'Akouda' and StringVar() == 'Peugeot':
      mbox.showinfo('resultat =('votre circuit : 'Akouda', votre voiture :'Peugeot')')
    if IntVar() == 'Sousse' and StringVar() == 'Peugeot':
       mbox.showinfo('resultat =('votre circuit : 'Sousse', votre voiture :'Peugeot')')
    if IntVar() == 'kalaa' and StringVar() == 'Clio':
       mbox.showinfo('resultat =('votre circuit : 'kalaa', votre voiture :'Clio')')
    if IntVar() == 'Akouda' and StringVar() == 'Clio':
      mbox.showinfo('resultat =('votre circuit : 'Akouda', votre voiture :'Clio')')
    if IntVar() == 'Sousse' and StringVar() == 'Clio':
      mbox.showinfo('resultat =('votre circuit : 'Sousse', votre voiture :'Clio')')
예제 #2
0
    def Main(self, params):
        #Close the window
        self.master.withdraw()
        vehsIgnored = self.vehsIgnored.get()
        satFlowHead = self.satFlowHead.get()
        minValidCycles = self.minValidCycles.get()
        minVehsPerMeas = self.minVehsPerMeas.get()

        csv_output_fp = r'Output_SatFlows.csv'
        dis_input_fp = self.fp_dis.get()
        #--------------------------------------------------------------------------------------------------------------#
        satFlow_data = self.GetDisData(dis_input_fp)

        #Keep the original Data in memory
        wt = satFlow_data
        #Remove the rows of the data where crossVehIdx <= VehsIgnored
        wt = self.RemoveIgnoredVehs(wt, vehsIgnored)
        #Return a dictionary with the total valid crossing time of vehicles for each Signal Head and Simulation
        satFlows = self.CalculateSatFlows(wt, satFlowHead, minValidCycles,
                                          minVehsPerMeas)
        #For the valid Signal Heads we can calculate the average of Saturation Flows
        #For the rest we print the list
        avgSatFlows = self.CalculateAvgSatFlows(satFlows)
        self.Output(csv_output_fp, avgSatFlows)
        completion_msg = 'End of execution - Results in {}'.format(
            csv_output_fp)
        print(completion_msg)
        messagebox.showinfo('Result', completion_msg)

        self.master.destroy()
예제 #3
0
def update():
    username = w.Entryusername.get()
    password = w.Entrypwd.get()
    password1 = w.Entrypwd1.get()
    qx1 = w.Entryqx.get()
    try:
        conn = pymysql.connect(host='localhost',
                               user='******',
                               passwd='809144',
                               db='mydb',
                               port=3306)
        cur = conn.cursor()
        cur.execute('select password from user where username = %s', username)
        r = cur.fetchone()
        if r != None:
            if r[0] != password:
                v.showerror('error', '旧密码输入错误')
            else:
                values = [password1, qx1, username]
                cur.execute(
                    'update user set password = %s,qx = %s where username = %s',
                    values)
                conn.commit()
                v.showinfo('successful', username + '信息已更新')
                cur.close()
        else:
            v.showerror('error', '不存在此用户')
            conn.close()
    except pymysql.Error as e:
        print('mysql error %d : %s' % (e.args[0], e.args[1]))
    sys.stdout.flush()
예제 #4
0
def Delete_Project(proj_ID, proj_manage_window):
    #Connect to database info file
    conn = sqlite3.connect("info.db")
    #Create database cursor
    c = conn.cursor()

    #Delete all tickets associated with project
    c.execute("DELETE FROM Tickets WHERE project_ID=?", proj_ID)

    #Update the project record with matching proj_ID
    c.execute("DELETE FROM Projects WHERE project_ID=?", proj_ID)
    messagebox.showinfo("Info", "Project deleted.")

    #Commit changes
    conn.commit()
    #Close connection
    conn.close()

    #Close the project manager
    proj_manage_window.destroy()

    #Refresh Table
    Display_Projects()

    return
예제 #5
0
def startclock():
    global stime_min, stime_sec, blockapp
    if not (stime_sec <= 0 and stime_min <= 0):
        stime_sec -= 1
        if stime_sec < 0:
            stime_sec = 59
            stime_min -= 1
        canvas.itemconfigure(c1,
                             extent=(onesec * (stime_min * 60 + stime_sec)))
        canvas.itemconfigure(
            clock,
            text=str(stime_min) + ":" +
            (str(stime_sec) if stime_sec > 9 else "0" + str(stime_sec)))

        if ((stime_min * 60 + stime_sec)
                == (sessiontime // 2)) and (settings[2] == "0"):
            # Breaktime
            takebreak()

        gui.after(1000, startclock)

    else:
        # Time ended, reset time
        global mainbutton
        mainbutton.config(image=mainbuttonimg, command=startsession)
        messagebox.showinfo("Session ended", "Your session has ended!")
        stop()
        #advsetexec()
        subprocess.Popen.terminate(blockapp)  # Kill the block.py
        stime_min = sessiontime // 60
        stime_sec = sessiontime % 60
예제 #6
0
    def confset():
        res = messagebox.askyesno(
            "Program Restart",
            "Değişikliklerin Kaydedilmesi için programın tekrar başlatılması gerekiyor \n Onaylıyorsun Değil mi ?"
        )
        if res:
            xm1en = m1en.get()
            xm2en = m2en.get()
            xm3en = m3en.get()
            xm4en = m4en.get()
            xm5en = m5en.get()
            xm6en = m6en.get()

            xm1in1 = m1in1.get()
            xm2in1 = m2in1.get()
            xm3in1 = m3in1.get()
            xm4in1 = m4in1.get()
            xm5in1 = m5in1.get()
            xm6in1 = m6in1.get()

            xm1in2 = m1in2.get()
            xm2in2 = m2in2.get()
            xm3in2 = m3in2.get()
            xm4in2 = m4in2.get()
            xm5in2 = m5in2.get()
            xm6in2 = m6in2.get()

            xs1 = s1.get()
            xs2 = s2.get()

            config.set('MOTORS', 'm1en', str(xm1en))
            config.set('MOTORS', 'm2en', str(xm2en))
            config.set('MOTORS', 'm3en', str(xm3en))
            config.set('MOTORS', 'm4en', str(xm4en))
            config.set('MOTORS', 'm5en', str(xm5en))
            config.set('MOTORS', 'm6en', str(xm6en))

            config.set('MOTORS', 'm1in1', str(xm1in1))
            config.set('MOTORS', 'm2in1', str(xm2in1))
            config.set('MOTORS', 'm3in1', str(xm3in1))
            config.set('MOTORS', 'm4in1', str(xm4in1))
            config.set('MOTORS', 'm5in1', str(xm5in1))
            config.set('MOTORS', 'm6in1', str(xm6in1))

            config.set('MOTORS', 'm1in2', str(xm1in2))
            config.set('MOTORS', 'm2in2', str(xm2in2))
            config.set('MOTORS', 'm3in2', str(xm3in2))
            config.set('MOTORS', 'm4in2', str(xm4in2))
            config.set('MOTORS', 'm5in2', str(xm5in2))
            config.set('MOTORS', 'm6in2', str(xm6in2))

            config.set("MOTORS", "s1", str(xs1))
            config.set("MOTORS", "s2", str(xs2))

            with open('config.ini', 'w') as configfile:
                config.write(configfile)
            restart_program()
        else:
            messagebox.showinfo("İptal", "Değişiklikler Kaydedilmedi !")
            confi.destroy()
예제 #7
0
    def add_ticker(self):
        """Add ticker to stock watchlist"""
        try:
            symbol = self.add_ticker_entry.get().upper()
            price = float(self.add_price_entry.get())
            pct_inc = float(self.percent_inc_entry.get())
            pct_dec = float(self.percent_dec_entry.get())
            price_low = price * (1 - pct_dec / 100)
            price_high = price * (1 + pct_inc / 100)
        except (ValueError, UnboundLocalError):
            messagebox.showinfo('ERROR: MISSING ENTRY FIELDS', \
                                'Please make sure all fields have valid info.')
            return

        # error message if not all entries filled else add ticker to db
        if len(symbol) == 0 or not price or not pct_dec or not pct_inc:
            messagebox.showinfo('ERROR: MISSING REQUIRED FIELDS', \
                                   "'Ticker Symbol', 'Price', and '% Dec' and "
                                   "'% Inc' are required fields.")
        else:
            db = create_connection('tickers.db')
            cursor = db.cursor()
            cursor.execute("""INSERT INTO symbols (ticker, price, pct_dec, pct_inc,
            price_low, price_high) VALUES (?, ?, ?, ?, ?, ?);""", \
            (symbol, '{:.2f}'.format(price), '{:.2f}'.format(pct_dec), \
             '{:.2f}'.format(pct_inc), '{:.2f}'.format(price_low), \
             '{:.2f}'.format(price_high)))

            close_connection(db)

            # clear out entry fields
            self.clear_entries()
예제 #8
0
def Delete_Ticket(ticket_ID, ticket_manage_window):
    #Connect to database info file
    conn = sqlite3.connect("info.db")
    #Create database cursor
    c = conn.cursor()

    #Update the ticket record with matching ID
    c.execute("DELETE FROM Tickets WHERE ticket_ID=?", (ticket_ID))
    messagebox.showinfo("Info", "Ticket deleted.")
    project_window.after(1, lambda: project_window.focus_force())

    #Update ticket_count
    c.execute("SELECT ticket_count FROM Projects WHERE project_ID=?", projID)
    count = c.fetchone()[0]
    
    c.execute("UPDATE Projects SET ticket_count=? WHERE project_ID=?", (count-1, projID))

    #Commit changes
    conn.commit()
    #Close connection
    conn.close()

    #Close the ticket manager
    ticket_manage_window.destroy()

    #Refresh tickets table
    Display_Tickets()

    return
예제 #9
0
    def add_nxt_que(self):
        "A function to add question in loop."\
        "It also doesn't allow the empty question and options to be saved and show a warning box ."

        que = self.que_txt.get()
        if que == "" or que == " ":
            tk.messagebox.showinfo("QuestionError",
                                   " The question-box should not be empty!")
            self.add_que()
        optns = {}
        for j in self.simp_var:
            optns[j] = self.optn_entry[j].get()
            if optns[j] == "" or optns[j] == " ":
                msg.showinfo("OptionsError",
                             " The options-box should not be empty!")
                self.add_que()
                break

        line = "_".join(optns.values())
        line = que + "_" + line
        set1 = []
        for char in line:  # Messes up(ciphers) data of the question and answer making unreadable
            set1.append(chr(ord(char) + 15))
        line = "".join(set1) + "\n"
        self.file.write(line)
        self.file.close()
        self.add_que()  # calls the same function to add question
예제 #10
0
def updatestudent():
    sno = w.Entry1.get()
    sname = w.Entry2.get()
    dept = w.Entry3.get()
    major = w.Entry4.get()
    class1 = w.Entry5.get()
    g1 = w.Entry6.get()
    conn = pymysql.connect(host='localhost',
                           user='******',
                           passwd='809144',
                           db='mydb',
                           port=3306)
    cur = conn.cursor()
    values = [sname, dept, major, class1, g1, sno]
    cur.execute('select * from student where sno = %s', sno)
    r = cur.fetchone()
    if r != None:
        cur.execute(
            'update student set sname = %s,sex = %s,sage = %s,dept = %s,class = %s where sno = %s',
            values)
        v.showinfo('successful', sname + '同学信息更新成功')
        conn.commit()
        cur.close()
        conn.close()
        destroy_window()
    else:
        v.showerror('error', sname + '同学信息不存在,请确认')
    sys.stdout.flush()
예제 #11
0
 def on_message(ws, message):
     msg = json.loads(message)
     if msg['type'] == 'taker':
         if (msg['data'][1] > 2) and (msg['data'][2] > msg['data'][1]):
             self.varMonitor.set('大单买入:%s' % msg['symbol'])
     if msg['type'] == 'quant':
         self.varMonitor.set('%s买入策略:%s' % (msg['symbol'], msg['name']))
         messagebox.showinfo("买入策略", self.varMonitor.get())
예제 #12
0
 def submit(self):
     print('City: {}'.format(self.entry_city.get()))
     print('State: {}'.format(self.entry_state.get()))
     print('Country: {}'.format(self.entry_country.get()))
     print('Name: {}'.format(self.entry_name.get()))
     print('Type: {}'.format(self.text_type.get(1.0, 'end')))
     self.clear()
     messagebox.showinfo(title = "Silk Road Historic Feature Survey", message = "Data successfully submitted - thank you!")
예제 #13
0
 def client_exit(self):
     if messagebox.askquestion("Decide", "Are you sure to exit?") == 'yes':
         self.master.destroy()
     else:
         messagebox.showinfo(
             'Return',
             'OK then, you will now return to the application screen')
     return
예제 #14
0
파일: rgou.py 프로젝트: groowe/RGOU
def game_ended(turn):
    if turn == 0:
        s = "white"
        opp = 2
    else:
        s = "black"
        opp = 0
    t = f"{s} won 7 : {7 - len(pieces[opp])}"
    showinfo("Window", t)
예제 #15
0
def button_process(root):
    #create message box
    messagebox.askokcancel('Python Tkinter',
                           'Are you sure to create a window?')
    messagebox.askquestion('Python Tkinter',
                           "Are you sure to create a window?")
    messagebox.askyesno('Python Tkinter', 'Are you sure to create a window?')
    messagebox.showerror('Python Tkinter', 'Unknown Error')
    messagebox.showinfo('Python Tkinter', 'hello world')
    messagebox.showwarning('Python Tkinter', 'Leave now')
    root1 = Toplevel(root)
예제 #16
0
 def showHelpPopup(self):
     showinfo(
         "Help", "To learn more about an option, move your mouse over it." +
         "\n" + limitedString(
             "You can generate multiple unique ROMs at once by changing the # of seeds.",
             55, "- ") + "\n" +
         limitedString(
             "You can also generate a text log that gives information about a created seed.",
             55, "- ") + "\n" +
         limitedString(
             "Generated ROMs will be placed in an \"output\" folder, which will be in the same folder as this program.",
             55, "- "))
예제 #17
0
 def play(self):
     if (len(playlist) == 0):
         tk2.showinfo(
             'Notice',
             'No songs in your playlist!\nClick Add to add songs.')
     else:
         pygame.mixer.music.stop()
         selectedSongs = self.playlistbox.curselection()
         global playlistbox
         playIt = playlist[int(selectedSongs[0])]
         pygame.mixer.music.load(playIt)
         pygame.mixer.music.play(0, 0.0)
def x_val():
    '''Function to check input value and generate x for calculating y'''
    try:
        x = int(txt.get())
        if x <= 700 and x >= 0:
            return [i for i in range(x)]
        else:
            raise Exception
    except Exception:
        messagebox.showinfo(
            "Error",
            "Please enter a positive integer in range 0 to 700 both inclusive")
        return None
예제 #19
0
    def attemptRandomize(self):
        global optionalRulesetsList
        global optRulesetValues

        optionalRulesetsList = [("", 0)] * len(optRulesetValues)
        for i in range(len(optRulesetValues)):
            optionalRulesetsList[i] = (Optional_Rulesets[i].name,
                                       int(optRulesetValues[i].get()))
        results = randomize()
        print("\n")
        if results[0]:
            showinfo("Success!", results[1])
        else:
            showerror("Error", results[1])
def own():
    dic = {'log': math.log, 'e': math.exp, 'sqrt': math.sqrt}
    y = []
    expr = txt.get()
    try:
        if 'x' not in expr:
            raise Exception

        for x in range(1, 401):
            dic['x'] = x
            y.append(eval(expr, {'__builtins__()': None}, dic))
        x = range(1, 401)
        plot(x, y)
    except Exception:
        messagebox.showinfo(
            "Error",
            "Please enter a valid expression in lower case 'x' containing:\n1. x\n2. log(x)\n3. e(x)\n4. sqrt(x)\n5. x**n (n is any integer)"
        )
예제 #21
0
def deletes():
    global f
    c = p('')
    w.Scrolledtreeview1.bind('<ButtonRelease-1>',p)
    if c.get('values') != '':
        cno = c.get('values')[0]
        conn = pymysql.connect(host = 'localhost', user = '******', passwd = '809144', db = 'mydb',port = 3306)
        cur = conn.cursor()
        cur.execute('DELETE FROM class WHERE cno = %s', cno)
        conn.commit()
        v.showinfo('suessful','删除成功')
    if f == 0:
        allfind()
    elif f == 2:
        cnofind()
    elif f == 1:
        namefind()
    sys.stdout.flush()
예제 #22
0
def login():
    global f1
    username = w.Entry_username.get()
    userpwd = w.Entry_password.get()
    try:
        conn = pymysql.connect(host = 'localhost', user = '******', passwd = '809144', db = 'mydb',port = 3306)
        cur = conn.cursor()
        if f1 == 1:
            if username != "" and userpwd != "":
                cur.execute('SELECT password FROM user WHERE username = %s and qx = 1',username)
                r = cur.fetchone()
                if r == None:
                    v.showerror(username,"不存在此用户")
                elif r[0]== userpwd:
                    v.showinfo(username,"登录成功")
                    destroy_window()
                    import manager
                    manager.vp_start_gui()
                else:
                    v.showerror(username,"登录失败,请检查用户名和密码")
            else:
                v.showerror(username, "用户名和密码不能为空")
        elif f1 == 0:
            if username != "" and userpwd != "":
                cur.execute('SELECT password FROM user WHERE username = %s and qx = 0',username)
                r = cur.fetchone()
                print(r)
                if r == None:
                    v.showerror(username, "不存在此用户")
                elif r[0] == userpwd:
                    v.showinfo(username, "登录成功")
                    destroy_window()
                    import teacher
                    teacher.vp_start_gui()
                else:
                    v.showerror(username, "登录失败,请检查用户名和密码")
            else:
                v.showerror(username, "用户名和密码不能为空")
        cur.close()
        conn.close()
    except pymysql.Error as e:
        print('mysql error %d : %s' % (e.args[0],e.args[1]))
    sys.stdout.flush()
예제 #23
0
    def remove_ticker(self):
        """Remove ticker from stock watchlist"""
        symbol = self.add_ticker_entry.get().upper()
        db = create_connection('tickers.db')
        cursor = db.cursor()
        cursor.execute("""SELECT count(*) FROM symbols WHERE ticker=?""",
                       (symbol, ))
        data = cursor.fetchone()[0]

        if data == 0:
            messagebox.showinfo("REMOVAL ERROR", \
                                   "Ticker doesn't exist in your watchlist.")
        else:
            cursor.execute("DELETE FROM symbols WHERE ticker=?;", (symbol, ))

            # clear out entry fields
            self.clear_entries()

        close_connection(db)
예제 #24
0
    def decryptor(self):
        key = self.Entry1.get()

        if len(key) == 32:
            ask = messagebox.askyesno(
                'ATTENTION : Are You Sure?',
                'Is this Key Correct?\n\nDecryption From Invalid Key Just\nGoing to Destroy your Data!!'
            )
            if ask == True:
                reverse = reverse_attack.Reverse(
                    key)  #Making object of Reverse Class
                reverse.start()  #Starts Decryption Process
                messagebox.showinfo(
                    'Decryption Process Completed : )',
                    'Decryption/Recovery of File is Completed Successfully!')
        else:
            messagebox.showerror(
                'Invalid Key',
                'You Entered Invalid Decryption Key.\nDecrytion from Invalid Key Will,\nJust Destroy Whole Data : ('
            )
예제 #25
0
def breakclock():
    global btime_min, btime_sec
    if not (btime_sec <= 0 and btime_min <= 0):
        btime_sec -= 1
        if btime_sec < 0:
            btime_sec = 59
            btime_min -= 1
        canvas.itemconfigure(c1,
                             extent=(bonesec * (btime_min * 60 + btime_sec)))
        canvas.itemconfigure(
            clock,
            text=str(btime_min) + ":" +
            (str(btime_sec) if btime_sec > 9 else "0" + str(btime_sec)))
        gui.after(1000, breakclock)

    else:
        btime_min = breaktime // 60
        btime_sec = breaktime % 60
        messagebox.showinfo("End of breaktime!", "Back to your work!")
        startsession()
예제 #26
0
def addgrade():
    cno = w.Entry1_6.get()
    cname = w.Entry1.get()
    credit = w.Entry1_1.get()
    if cno == "" or cname == "":
        v.showerror("错误","课程和课程名不能为空")
    else:
        conn = pymysql.connect(host='localhost', user='******', passwd='809144', db='mydb', port=3306)
        cur = conn.cursor()
        cur.execute("SELECT * FROM class WHERE cno = %s",cno)
        r = cur.fetchone()
        if r == None:
            values = [cno,cname,credit]
            cur.execute('INSERT INTO class VALUES(%s,%s,%s)',values)
            conn.commit()
            v.showinfo(cno, "添加成功")
        else:
            v.showerror("错误", "该课程信息已经存在,请检查后添加")
    cur.close()
    conn.close()
    sys.stdout.flush()
예제 #27
0
def reveal(frame, board, zone, bfs, mine_coords):
    """
    Reveal square on click.

    Lose and exit if the square is a mine.
    Win and disable buttons when all squares except mines are cleared.
    """
    #~ global BUTTON_WIDTH
    #~ zone.button = tk.Button(frame, bg="grey", fg="black", height=1, width=BUTTON_WIDTH, relief="sunken", text=zone.value)
    #~ # zone_button.grid(row=zone.y, column=zone.x)
    # zone_button = frame.grid_slaves(row=zone.y, column=zone.x)[0]
    zone.button.config(bg="grey")
    zone.button.config(relief="sunken")
    zone.button.config(text=zone.value)
    zone.button.config(command=None)
    zone.button.unbind("<Button-3>")

    if zone.value is "M":
        tkMessageBox.showinfo("KABOOM", "Stepped on a mine.")
        for coord in mine_coords:
            current_mine_zone = board[coord[1]][coord[0]]
            current_mine_zone.button.config(bg="dark red")
            current_mine_zone.button.config(text=current_mine_zone.value)
        for b in frame.winfo_children():
            b.configure(state="disabled")
            b.unbind("<Button-3>")

    if not zone.revealed:
        global squares_left
        # global total_mines
        squares_left -= 1
        zone.revealed = True
    if squares_left == total_mines:
        tkMessageBox.showinfo("CLEAR", "You win!")
        for b in frame.winfo_children():
            b.configure(state="disabled")
            b.unbind("<Button-3>")
    if (bfs) and (zone.value == 0):
        clear_adjacent(board, zone, mine_coords)
def updates():
    sno = w.Entry1.get()
    cno = w.Entry2.get()
    grade = w.Entry4.get()
    conn = pymysql.connect(host='localhost',
                           user='******',
                           passwd='809144',
                           db='mydb',
                           port=3306)
    cur = conn.cursor()
    values = [grade, sno, cno]
    cur.execute('select * from student where sno = %s', sno)
    r = cur.fetchone()
    if r != None:
        cur.execute('update grade set grade = %s where sno = %s and cno = %s',
                    values)
        v.showinfo('successful', sno + '成绩信息更新成功')
        conn.commit()
        cur.close()
        conn.close()
        destroy_window()
    sys.stdout.flush()
예제 #29
0
def delete():
    username = w.Entry1.get()
    try:
        conn = pymysql.connect(host='localhost',
                               user='******',
                               passwd='809144',
                               db='mydb',
                               port=3306)
        cur = conn.cursor()
        cur.execute('SELECT username FROM user WHERE username = %s', username)
        r = cur.fetchone()
        if r == None:
            v.showerror("error", "不存在该用户名")
        else:
            cur.execute('DELETE FROM user WHERE username = %s', username)
            conn.commit()
            v.showinfo('suessful', username + '删除成功')
        cur.close()
        conn.close()
    except pymysql.Error as e:
        print('mysql error %d : %s' % (e.args[0], e.args[1]))
    sys.stdout.flush()
예제 #30
0
    def __create_lockfile(self, reg_exit):
        if psutil is None:
            messagebox.showinfo("Notice", "The dependencies to protect against corruption via running multiple instances of this program are not present. Be sure not to have multiple instances of this program open at once.")
            return
        
        lockfile = os.path.join(self.__base, Storage.LOCKFILE)
        if os.path.exists(lockfile):
            # check if written PID refers to a living python process
            f = open(lockfile, 'r')
            _pid = f.read()
            f.close()

            override = True
            try:
                pid = int(_pid)
                try:
                    proc = psutil.Process(pid)
                    if proc.name() == "python" or proc.name() == "python3":
                        override = False
                except psutil.NoSuchProcess:
                    pass
            except ValueError:
                pass # invalid PID? lockfile wasn't generated by this.

            if override:
                f = open(lockfile, 'w')
                f.write(str(os.getpid()))
                f.close()
            else:
                raise LockfileError("To-do data is locked, make sure no other instance is running!")
            
        else:
            f = open(lockfile, 'w')
            f.write(str(os.getpid()))
            f.close()

        if reg_exit is not None:    
            reg_exit(self.__dereg)
예제 #31
0
파일: menu.py 프로젝트: hopsmdev/playground
 def save(cls):
     messagebox.showinfo("Save", "Save something")
예제 #32
0
 def quit(self):
     if self.okayToQuit():                                # threads running?
         if askyesno(self.__app, 'Verify Quit Program?'):
             self.destroy()                               # quit whole app
     else:
         showinfo(self.__app, 'Quit not allowed')         # or in okayToQuit?
예제 #33
0
 def quit(self):
     showinfo('Quit', 'Not supported in attachment mode')
예제 #34
0
파일: menu.py 프로젝트: hopsmdev/playground
 def new(cls):
     messagebox.showinfo("New", "Create new something")
예제 #35
0
 def hello(self):
     name = self.nameInput.get() or 'world'
     messagebox.showinfo('Message', 'Hello, %s' % name)
예제 #36
0
파일: menu.py 프로젝트: hopsmdev/playground
 def open(cls):
     messagebox.showinfo("Open", "Open something")
예제 #37
0
 def showInfoBox(self):
     messagebox.showinfo("Message", "Today is Thursday")
예제 #38
0
파일: menu.py 프로젝트: hopsmdev/playground
 def help(cls):
     messagebox.showinfo("Help", "It should help ...")
예제 #39
0
파일: menu.py 프로젝트: hopsmdev/playground
 def about(cls):
     messagebox.showinfo("About", "About this program")
예제 #40
0
 def help(self):
     "override me in subclass"
     showinfo('Help', 'Sorry, no help for ' + self.__class__.__name__)