37,720
社区成员
发帖
与我相关
我的任务
分享
#-*-coding: gbk-*-
from DxVcl import *
class MainForm(Form):
def __init__(self, Owner):
self.Caption = "A Delphi Form..."
self.SetBounds(10, 10, 500, 400)
self.Btn = Button(self)
self.Btn.SetProps(Parent=self, Caption="测试说明")
self.Btn.SetBounds(10, 44, 100, 64)
self.lblHello = Label(self)
self.lblHello.SetProps(Parent=self, Caption="Hello World")
self.lblHello.SetBounds(10, 10, 80, 24)
self.OnClose = self.MainFormClose
self.Btn.OnClick = self.BtnClick
def BtnClick(self,Sender):
self.Caption = "测试不得闲"
ShowMessage(StrToHex(self.Caption))
ShowMessage(''.join(['16进制转换回来:',HexToStr(StrToHex(self.Caption))]))
ShowMessage(IntToStr(234234))
def MainFormClose(self, Sender, Action):
Action.Value = caFree
class DxLogForm(Form):
def __init__(self,Owner):
self.Caption = '不得闲测试窗体'
self.Position = 5
self.BorderStyle = 3
self.Width = 234
self.Height = 150
self.lb1 = Label(self)
self.lb1.SetProps(Parent = self,Caption = '用户')
self.lb1.SetBounds(40,16,28,13)
self.EdtUser = Edit(self)
self.EdtUser.SetProps(Parent = self,Text = 'dxsoft')
self.EdtUser.SetBounds(77,13,121,21)
self.lb2 = Label(self)
self.lb2.SetProps(Parent = self,Caption = '密码')
self.lb2.SetBounds(40,48,28,13)
self.EdtPwd = Edit(self)
self.EdtPwd.SetProps(Parent = self,Text = 'dxsoft',PasswordChar='*')
self.EdtPwd.SetBounds(77,45,121,21)
self.BtnLog = Button(self)
self.BtnLog.SetProps(Parent = self,Caption = '登录')
self.BtnLog.SetBounds(25,80,75,25)
self.BtnLog.OnClick = self.BtnClick
self.BtnCancel = Button(self)
self.BtnCancel.SetProps(Parent = self,Caption = '取消')
self.BtnCancel.SetBounds(141,80,75,25)
self.BtnCancel.OnClick = self.BtnCancelClick
def BtnClick(self,Sender):
if self.EdtPwd.Text.decode('gbk') == '123':
ShowMessage('登录成功,打开主窗体')
#self.visible = false
#打开另一个窗体
self.ModalResult = mrok
else:
ShowMessage('密码为123')
def BtnCancelClick(self,Sender):
self.Close()
def dolog():
LogFrm = DxLogForm(None)
m = LogFrm.ShowModal() == mrok
LogFrm.Free()
return m
def main():
FreeConsole()
if dolog():
Application.Initialize()
Application.Title = 'TestApp'
f = MainForm(Application)
f.Show()
Application.Run()
else:
ShowMessage('用户取消了登录')
if __name__=='__main__':
main()