def openParameterFile(self, hwnd): args = { 'hwndOwner': hwnd, 'Filter': "Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0", 'FilterIndex': 1, 'DefExt': "txt", 'Flags': win32con.OFN_EXPLORER | win32con.OFN_FILEMUSTEXIST | win32con.OFN_HIDEREADONLY } try: file_name = win32gui.GetOpenFileNameW(**args)[0] if file_name: try: parameter_file = open(file_name, "r") for i in range(len(self._pixels)): line = parameter_file.readline() row, col = line.split(", ") self._pixels[i] = [float(row), float(col)] parameter_file.close() except Exception, e: print str(e) win32gui.MessageBox(None, "Error reading parameter file!", "Error", win32con.MB_ICONERROR | win32con.MB_OK) except: # no file selected pass
def OnKeyUp(self, hwnd, msg, wparam, lparam): # reset _first_keydown for the next keypress self._first_keydown = True # redraw the window win32gui.RedrawWindow( hwnd, None, None, win32con.RDW_INVALIDATE | win32con.RDW_INTERNALPAINT) if self._display_string: # invalidate the onscreen display win32gui.InvalidateRect(hwnd, self._onscreen_display, True) if self._show_help: self._show_help = False # show help dialog box win32gui.MessageBox( None, "Up Arrow: move selected pixel up\n" + "Down Arrow: move selected pixel down\n" + "Right Arrow: move selected pixel right\n" + "Left Arrow: move selected pixel left\n" + "Plus: change pixel increment to 10 pixels\n" + "Minus: change pixel increment to 1 pixel\n" + "N: select next pixel\n" + "P: select previous pixel\n" + "F: toggle full screen\n" + "O: open pixel file\n" + "S: save pixel file\n" + "Q: quit\n" + "Shift: show select pixel number\n" + "Control: show current pixel increment\n", "Help", win32con.MB_ICONINFORMATION | win32con.MB_OK)
def saveParameterFile(self, hwnd): args = { 'hwndOwner': hwnd, 'Filter': "Text Files (*.txt)\0*.txt\0All Files (*.*)\0*.*\0", 'FilterIndex': 1, 'DefExt': "txt", 'Flags': win32con.OFN_EXPLORER | win32con.OFN_FILEMUSTEXIST | win32con.OFN_HIDEREADONLY } try: file_name = win32gui.GetSaveFileNameW(**args)[0] if file_name: try: parameter_file = open(file_name, "w") for pixel in self._pixels: parameter_file.write("%.1f, %.1f\n" % (pixel[0], pixel[1])) parameter_file.close() except Exception, e: print str(e) win32gui.MessageBox(None, "Error saving parameter file!", "Error", win32con.MB_ICONERROR | win32con.MB_OK) except: # no file selected pass
def DisplayItem(shell_item_array, hwnd_parent=0): # Get the first ShellItem and display its name if shell_item_array is None: msg = "You must select something!" else: si = shell_item_array.GetItemAt(0) name = si.GetDisplayName(shellcon.SIGDN_NORMALDISPLAY) msg = "%d items selected, first is %r" % (shell_item_array.GetCount(), name) win32gui.MessageBox(hwnd_parent, msg, "Hello", win32con.MB_OK)
def onSetting3(items, bindctx): win32gui.MessageBox(0, LoadString(IDS_SETTING3), "Hello", win32con.MB_OK)
django.setup() from django.conf import settings # Initialize logging try: cx_Logging.StartLogging( os.path.join(settings.FREPPLE_LOGDIR, "systemtray.log"), level=cx_Logging.INFO, maxFiles=1, prefix="%t", ) except: win32gui.MessageBox( None, "The folder %s doesn't exist or is not writeable for your user" % settings.FREPPLE_LOGDIR, "Error", win32con.MB_OK, ) sys.exit(1) # Redirect all output logfile = os.path.join(settings.FREPPLE_LOGDIR, "server.log") sys.stdout = sys.stderr = open(logfile, "w") # Parse command line parser = argparse.ArgumentParser(description="Runs a web server for frePPLe.") parser.add_argument("--port", type=int, help="Port number of the server.") parser.add_argument("--address", help="IP address to listen on.") options = parser.parse_args()
def Show(message, title='', style=S_OK): return winxpgui.MessageBox(0, message, title, style)