Hey Guys, I’m hoping someone could shed some light on my little problem here
I’ve been trying to create a wxTextEntryDialog() within this script here and for some reason I am not getting any return from the ShowModal() call. Although the dialog pops up just fine and when I press the Ok or Cancel button(s) it closes the dialog just fine, it seems that the dialog still does not exit properly as whenever the ShowModal() call is made, all code written afterwards will not run. Even code after the “if passdlg.ShowModal() == wx.ID_OK:” (and trailing else: line) will not run, which includes the “print temp” line, which is after the if/else statement so it should be run after the Ok or Cancel button have been pressed.
What is driving me nuts the most is that the same code for the TextEntryDialog() is used in another window for this application and it works just fine but within this script it just locks up like ShowModal() wont exit properly.
I have also tried to create my own custom dialog with wxDialog, using different ids for the Ok & Cancel buttons, incase there was an id confliction, but that didn’t seem to help at all either.
As well, no errors are generated from this code which leaves me little to go on and I am completely out of ideas.
Any suggestions would be appreciated as I am completely stuck atm and I REALLY need to get the dialog working properly!
import wx, os, sys, thread, random
from Resources import Variables as variables
from Resources.Modules import win32tests as kroll
from Resources.Controls import Services as svc
from Resources.Controls import Notebook1 as nb
from Resources.Controls import TaskBarIcon as tbi
from Resources.Controls import Dialog as dlg
from Resources.Controls import servicewindow as advsvc
ImageDir = variables.ImageDir
ids = [‘FILEEXIT’, ‘TOOLSDISFWALL’, ‘TOOLSBACKUP’, ‘TOOLSRESTORE’, ‘HELPABOUT’]
for a in ids: exec “ID_%s = wx.NewId()” % (a)
class Main(wx.Frame):
def __init__(self, parent):
wx.Frame.__init__(self, parent, -1, "KHW Toolbox", wx.Point(171, 114), wx.Size(800, 600),
wx.DEFAULT_FRAME_STYLE | wx.FULL_REPAINT_ON_RESIZE)
self.TrayIcon = tbi.TaskBarIcon(self, wx.Icon(ImageDir + '\\icon16.png', wx.BITMAP_TYPE_PNG), "KHW Toolbox")
self.Split = wx.SplitterWindow(self, -1, style=wx.SP_LIVE_UPDATE | wx.SP_3D)
self.Split1 = wx.SplitterWindow(self.Split, -1, style=wx.SP_LIVE_UPDATE | wx.SP_3D)
self.Panel1 = svc.Services(self.Split, -1)
self.TextCtrl = wx.TextCtrl(self.Split1, -1, style=wx.RAISED_BORDER | wx.HSCROLL | wx.TE_MULTILINE | wx.TE_DONTWRAP | wx.TE_READONLY)
self.Notebook = nb.Notebook(self.Split1, -1)
self.Split.SetMinimumPaneSize(20)
self.Split1.SetMinimumPaneSize(20)
self.Split.SplitVertically(self.Panel1, self.Split1, 220)
self.Split1.SplitHorizontally(self.TextCtrl, self.Notebook, -100)
self.Split1.SetSashSize(4)
self.TextCtrl.SetBackgroundColour("black")
self.TextCtrl.SetForegroundColour("white")
self.TextCtrl.SetFont(wx.Font(8, wx.SWISS, wx.NORMAL, wx.NORMAL, False, 'Currier'))
self.TextCtrl.ChangeValue(kroll.Win().WindowsInfo())
self.SetIcon(wx.Icon(ImageDir + '\\icon32.png', wx.BITMAP_TYPE_PNG))
self.Bind(wx.EVT_MENU, self.OnMenuSelected)
self.DoMenuBar()
self.DoStatusBar()
def OnMenuSelected(self, event):
if event.GetId() == ID_TOOLSDISFWALL:
# ID matches fine and runs the below code
passdlg = wx.TextEntryDialog(self, 'Enter Password:', 'Administrative Login', '')
# Dialog is called and pops up fine
if passdlg.ShowModal() == wx.ID_OK:
# "print 'working!'" line does not print when Ok is pressed and "temp" is not set
print 'working!'
temp = passdlg.GetValue()
else:
# "print 'BAHHHH!' line does not print when Cancel is pressed
print 'BAHHHH!'
passdlg.Destroy()
# "print temp" does not print after Ok or Cancel print, no errors are generated
print temp
def DoStatusBar(self):
self.StatusBar = wx.StatusBar(self, -1)
self.SetStatusBar(self.StatusBar)
def DoMenuBar(self):
self.File = wx.Menu(title='')
self.Tools = wx.Menu(title='')
self.View = wx.Menu(title='')
self.Help = wx.Menu(title='')
self.MenuBar = wx.MenuBar()
self.File.Append(ID_FILEEXIT, 'E&xit', 'Exit KrollHW Toolbox', kind=wx.ITEM_NORMAL)
self.Tools.Append(ID_TOOLSDISFWALL, '&Disable All Firewalls', 'Attempts to disable "Windows Firewall" service on selected computers found within the network', kind=wx.ITEM_NORMAL)
self.Tools.Append(ID_TOOLSBACKUP, '&Backup Database', '', kind=wx.ITEM_NORMAL)
self.Tools.Append(ID_TOOLSRESTORE, '&Restore Database', '', kind=wx.ITEM_NORMAL)
self.Help.Append(ID_HELPABOUT, 'A&bout', 'Displays help information', kind=wx.ITEM_NORMAL)
self.MenuBar.Append(menu=self.File, title='&File')
self.MenuBar.Append(menu=self.Tools, title='&Tools')
self.MenuBar.Append(menu=self.Help, title='&Help')
self.SetMenuBar(self.MenuBar)
if name == ‘main’:
app = wx.PySimpleApp()
frame = Main(None)
frame.Show()
app.MainLoop()