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

# -*- 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

posted @ 2012-09-16 13:23  麦峰强  阅读(1396)  评论(0编辑  收藏  举报