Esempio n. 1
0
def main():
    # 初始化历史文件
    linenotebase.initFile(fileName)
    # 创建UDP-socket
    s = socket.socket(socket.AF_INET,socket.SOCK_DGRAM)
    # 绑定端口:
    s.bind((serverAddr,serverPort))
    # 显示绑定udp参数
    print 'listening...'
    # 进入udp接收循环
    while True:
        # 接收数据:
        data, addr = s.recvfrom(1024)
        # 如果输入为history则显示历史内容
        if data=='history':
            # 遍历记录文件,默认20行
            history=linenotebase.historyNote(fileName,20)
            # 把遍历内容发给请求者
            s.sendto(history, addr)
        else:
            linenotebase.writeNote(fileName,data)
            print data
Esempio n. 2
0
def main():
    # 初始化文件内容
    linenotebase.initFile(fileName)
    # 生成frame对象
    app = Application()
    # 设置窗口标题:
    app.master.title('linenoteGUI')
    # 设置窗口大小
    appWidth = 600
    appheight = 200
    # 使窗口居中显示
    scnWidth,scnHeight = app.master.maxsize()
    tmpcnf = '%dx%d+%d+%d'%(appWidth, appheight, (scnWidth-appWidth)/2, (scnHeight-appheight)/4)
    # tmpcnf = '%dx%d+%d+%d'%(appWidth, appheight, (scnWidth-appWidth)/2, 200)
    # 调整初始窗口大小
    app.master.geometry(tmpcnf)
    # 设置最小窗口大小
    app.master.minsize(appWidth, appheight)
    # 固定窗口大小不可改变
    app.master.resizable(width=False, height=False)
    # 主消息循环:
    app.mainloop()