Bombinaid 

      Login / Register  Bombinaid.com Home  INDEX
 
 









   How to make a Tips dialog in wxPython
Admin
Page Options:

Printable Page

1260 Views

By Ajm113 - 2007

Whats a Tips dialog?

A tips dialog is a window that usually pops up and shows a tip of your program. It tells the user a neat trick that they can use for your program.
Its a good way to give users more knowledge of your program so they wont be sending you emails on using it all the time.

First Off

Lets go to where you have your program at and add in a ".txt" file and name it "tips.txt". This will store our tips. Lets put in some tips!

Copy This & Paste In tips.txt.


#This will not be shown for this is a comment.
#tip1
Press Alt+F4 to exit.
#tip2
You can reach me at myemail@something.com


As you can see each line is one tip you can't put in returns in those lines other wise your tips will be cut off.
The "#" needs to in front of your comment so the Tip of the day dialog wont read it.

Now lets do some Python codding!

self.SetTopWindow(frame) #This will tell this is a frame
provider = wx.CreateFileTipProvider("tips.txt", 0) #This does the dialog stuff like the "Next Tip".
wx.ShowTip(None, provider, False) #Define more of it.



Now add that code in the area where more of your program's frame is being deffine. It mite look like something like this.

class App(wxApp):
def OnInit(self):
frame = MainFrame(NULL, -1, 'My Program', wxDefaultPosition, wxDefaultSize)
wxApp.__init__(self)
frame.Show(True)

#Show Tips Code>>>

return True


App(0).MainLoop()


When you add in the Show tips between the two commands the show tips should run when you just execute your program.
If you where to add the show tips in the first window deffining area the show tips would show before your main frame even runs.
Now also so I don't forget wx.CreateFileTipProvider("tips.txt", 0) the first function tells where you have your tips.txt is.
The second function tells which line to read. Like if I enter "11" it will read line 11 in the text file.

That should be it, thanks for reading!
Ajm113 - Site Admin




7 + 16 = characters left