python小工具收集-----GUID2class

来源:互联网 发布:标准动车组 知乎 编辑:程序博客网 时间:2024/05/17 02:05
# -*- coding: utf-8 -*-
'''
Created on 2012-9-16

@author: IBM
'''
from Tkinter import *
from docutils.nodes import row
from win32event import *
from win32api import *
import win32api

class EntryFormatting:
def __init__(self, master):
frame = Frame(master)
Label(frame, text=' ').grid(row=0, column=0, sticky=W)
Label(frame, text=' ').grid(row=0, column=3, sticky=W)

self._EdtGUID=self.createField(frame, width=26, row=0, col=2,
label='GUID', format=self.fmtGUID,
enter=self.activate, change=self.edtChg)
self._LabelclsName = self.createField(frame, width=26, row=1, label='程序名',
col=2, enter=self.activate)
frame.pack(side=TOP, padx=15, pady=15)

def createField(self, master, label='', text='', width=1, format=None,
enter=None, row=0, col=0, change=None):
Label(master, text=label).grid(row=row, column=col-1, padx=15, sticky=W)
id = Entry(master, text=label, width=width, takefocus=1)
id.bind('<KeyRelease>', format)
id.bind('<<Modified>>', change)
id.bind('<Return>', enter)
id.grid(row=row, column=col, pady=10, sticky=W)

def activate(self, event):
print '<Return>: value is', event.widget.get()

def fmtGUID(self, event):
current = event.widget.get()
from test.test_iterlen import len
if len(current) != 16:
self._EdtGUID.text = 'please input right GUID'

def edtChg(self, event):
''''''
handle = win32api.LoadLibrary('ole32')
funcProgIdFromClsid = win32api.GetProcAddress(handle, 'ProgIDFromCLSID')
lpszProgid = ''
funcProgIdFromClsid(lpszProgid, event.widget.get())
self._LabelclsName.text = lpszProgid

if __name__ == '__main__':
root = Tk()
root.title('GUID2Class')

top = EntryFormatting(root)
quit = Button(root, text="Quit", command=root.destroy)
quit.pack(side="bottom")

root.mainloop()
pass

0 0
原创粉丝点击