· 7 years ago · Apr 16, 2018, 11:58 PM
1 userkey = ''
2 secretkey = ''
3 #-----------------------------------------------------#
4 f = open("config.ini","r")
5 for i in f:
6
7 if i.find("userkey=") >= 0:
8 cuenta_letras = len('userkey=')
9 userkey = i[cuenta_letras:]
10
11 if i.find("secretkey=") >= 0:
12 cuenta_letras = len('secretkey=')
13 secretkey = i[cuenta_letras:]
14 #-----------------------------------------------------#
15
16 dialog = wx.TextEntryDialog(None, "Clave de acceso","Cd Key", userkey, style=wx.OK|wx.CANCEL| wx.CENTRE)
17
18 if dialog.ShowModal() == wx.ID_OK:
19 #print ("Usuario de acceso: %s" % dialog.GetValue())
20 userkey = dialog.GetValue()
21
22 password = wx.TextEntryDialog(None, "Password", "Password", secretkey)
23 if password.ShowModal() == wx.ID_OK:
24 secretkey = password.GetValue()
25 #print ("Clave de acceso: %s" % password.GetValue())
26 #-----------------------------------------------------#
27
28 f = open("config.ini","r+")
29 d = f.readlines()
30 f.seek(0)
31 for i in d:
32 if i.find("userkey=") != 0 and i.find("secretkey=") != 0:
33 f.write(i)
34 f.truncate()
35
36 #-----------------------------------------------------#
37 f.write('\n')
38 f.write("userkey="+str(userkey)+'\n')
39 f.write("secretkey="+str(secretkey)+'\n')
40 f.close()
41
42 #-----------------------------------------------------#
43 # Limpiar lineas vacias #
44 #-----------------------------------------------------#
45 f = open("config.ini","r+")
46 d = f.readlines()
47 f.seek(0)
48 for i in d:
49 if len(i) > 3:
50 f.write(i)
51 f.truncate()
52 f.close()