Creating GUI extra's for Mushclient: Part 1

by Unknown

Back to Mechanic's Corner.

Unknown2006-10-31 11:29:23
Ok, after long fight with docs I did it. Though, it doesnt set background nor foreground colour. Isn't it possible to set it?
Unknown2006-10-31 12:12:54
Maybe you're just not reading everything... In your button press handler, just toggle the colors. That's the easy part, if you ask me. You've done the hard part already.
Unknown2006-11-05 00:40:50
CODE

def OnClick(self, evt):
       btn = evt.GetEventObject()
       if btn.GetValue():
             btn.SetFont(wx.Font(8, wx.ROMAN, wx.NORMAL, wx.FONTWEIGHT_BOLD, False))
             btn.SetBackgroundColour(wx.Colour(255,60,26))
       else:
             btn.SetFont(wx.Font(8, wx.ROMAN, wx.NORMAL, wx.NORMAL, False))
             btn.SetBackgroundColour(wx.Colour(255,255,255))
       self.Refresh()

   def AddButton(self, parent, id, label, position, size):
       b = buttons.wx.ToggleButton(parent, id, label, position, size)
       self.Bind(wx.EVT_TOGGLEBUTTON, self.OnClick, b)
       b.SetFont(wx.Font(8, wx.ROMAN, wx.NORMAL, wx.NORMAL, False))
       b.SetForegroundColour(wx.Colour(255,255,255))
       b.SetBackgroundColour(wx.Colour(31,60,26))


As you can see in the OnClick routine, there is font and background colour change. Font change works, colour not. why?
Unknown2007-04-25 22:50:59
Ok,

So I was wondering. I have been looking over the wondering tutorial you have set up and was curious.

I'm brand new to Mushclient and was told to use Lua. But which one is better? Python or Lua and which is easier to use?

Thanks
Daganev2007-04-25 23:16:21
Python is better in the long run, Lua sounds easier to use/learn.
Arundor2007-04-26 00:14:35
Lua reportedly runs faster, and works if you're using MUSHClient on Linux with Wine.

Python tends to be more popular in general, so it's a good choice if you want your coding experience to benefit you outside Lusternia.
Unknown2007-04-26 13:22:10
Alright.

Thanks for the help.

***EDIT****

Ok, so I downloaded everything and started following the tutorial and I think I am doing something wrong since it doesn't seem to be working. Here is the code so far...

*Code*

import wx

class MainWindow(wx.MiniFrame):
def_init_(self, titles, pos=wx.DefaultPosition, size=(200,200),
style=wx.STAY_ON_TOP|wx.DEFAULT_FRAME_STYLE):
wx.MiniFrame._init_(self, None, -1, title, pos, size, style)

self.Show(True)

if_name_=="_main_":
app = wx.App()
app.frame = MainWindow("Compass")
app.MainLoop()

As I said, I believe I have followed the things correctly but I may have made some mistakes that I can not find. If anyone can point them out to me, it would be greatly appreciated.

Thanks again for all the help.
Unknown2007-04-26 18:23:37
It would help if you specified HOW it doesn't work. Do you get an error message? Just no window? What happens to indicate failure?

Also, did you indent your lines properly? Python requires indentation. Can't tell from posting without proper CODE tags if it's indented or not...
Unknown2007-04-26 22:51:39
import wx

class MainWindow(wx.MiniFrame):
def __init__(self, title, pos=wx.DefaultPosition, size=(200,200),
style=wx.STAY_ON_TOP|wx.DEFAULT_FRAME_STYLE):
wx.MiniFrame._init_(self, None, -1, title, pos, size, style)

self.Show(True)

if_name_=="_main_":
app=wx.App()
app.frame=MainWindow("Compass")
app.MainLoop()

There is the code. I hope that makes it a bit easier. The error I get just says Failed to run script - syntax error - invalid syntax.

Also, not sure if this has anything to do with it, but when I try to run it, I get the error and it puts the cursor by the part that says if_name_=="_main_:

Again, not sure if that matters since it doesn't really highlight anything specific.

Thanks again for all the help.

****Edit***

I deleted my original try and decided to copy the way you had things done and paste them in and everything worked fine. So I know there has to be an error with how I am doing it.
Unknown2007-04-26 22:57:23
I've never used Python before, but just by looking at the OP it looks like two underscores __ instead of the one that you're using. See if that makes a difference. I'm talking about the if_name_ deal, by the bye.
Unknown2007-04-26 23:01:29
import wx

class MainWindow(wx.MiniFrame):
def_init_(self, title, pos=wx.DefaultPosition, size=(200,200),
style=wx.STAY_ON_TOP|wx.DEFAULT_FRAME_STYLE):
wx.MiniFrame._init_(self, None, -1, title, pos, size, style)

self.Show(True)

if_name_=="_main_":
app=wx.App()
app.frame=MainWindow("Compass")
app.MainLoop(

Ok so I changed the two underscores just as you suggested and took out the extra space I had for some reason between def and init. Tried it again. Got the same error but this time it highlighted the () around def_init_(self....to the end at STYLE)
Unknown2007-04-27 01:11:06
QUOTE(True_Infernal @ Apr 26 2007, 07:01 PM) 401980
Ok so I changed the two underscores just as you suggested and took out the extra space I had for some reason between def and init. Tried it again. Got the same error but this time it highlighted the () around def_init_(self....to the end at STYLE)


I think you changed the wrong underscores. Try this?

CODE
import wx

class MainWindow(wx.MiniFrame):
  def __init__(self, title, pos=wx.DefaultPosition, size=(200,200),
                   style=wx.STAY_ON_TOP|wx.DEFAULT_FRAME_STYLE):
    wx.MiniFrame.__init__(self, None, -1, title, pos, size, style)

    self.Show(True)

if __name__ == "__main__":
  app=wx.App()
  app.frame=MainWindow("Compass")
  app.MainLoop()


I don't have Python or wxPython on my PC to test it, and my Python's a bit rusty besides.