1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
from Tkinter import *
from threading import *
from datetime import date, tzinfo, timedelta, datetime
import MySQLdb
import time
import sys
# Initialisation de la base
conn = MySQLdb.connect('IP-DU-SERVEUR','root','MDP', 'TABLE')
print "2 Debut SQL"
# La requete Mysql
curs = conn.cursor()
requete=curs.execute("select * from exemple;" )
variable=curs.fetchall()
#On cree l interface
import wx
import wx.calendar
class MyFrame(wx.Frame):
def __init__(self, parent, title):
wx.Frame.__init__(self, parent, -1, 'form title', wx.DefaultPosition, (250, 116), style=wx.CLOSE_BOX | wx.SYSTEM_MENU | wx.CAPTION | wx.RESIZE_BORDER | 0 | 0 | wx.MAXIMIZE_BOX | wx.MINIMIZE_BOX)
self.panel = wx.Panel(self, -1)
#J injecte ici la variable dans l interface
self.Resultat = wx.StaticText(self.panel, -1, '%s' % (varirable), (144,32), (64, 21))
self.Resultat.SetFont(wx.Font(8, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, 'Microsoft Sans Serif'))
self.Resultat.SetCursor(wx.StockCursor(wx.CURSOR_DEFAULT))
self.label2 = wx.StaticText(self.panel, -1, 'La valeur est :', (32,32), (110, 27))
self.label2.SetFont(wx.Font(8, wx.FONTFAMILY_DEFAULT, wx.FONTSTYLE_NORMAL, wx.FONTWEIGHT_NORMAL, 0, 'Microsoft Sans Serif'))
self.label2.SetCursor(wx.StockCursor(wx.CURSOR_DEFAULT))
#---------------------------------------------------------------------------
class MyApp(wx.App):
def OnInit(self):
frame = MyFrame(None, 'App')
frame.Show(True)
self.SetTopWindow(frame)
return True
app = MyApp(True)
app.MainLoop() |
Partager