NoisyNoise 0 Posted April 2, 2020 Share Posted April 2, 2020 Hi everyone! Im a newbie in programming so i have to ask about buttons in gui. Im trying to add 2 small buttons to that script but i dont have any idea how. I was tried some options but doesn't work. Can anyone help me and give me instructions how to add working buttons? Spoiler import ui,app,time,chr,math,playerSettingModule try: import playerm2g2 as player chr.GetPixelPosition = player.GetMainCharacterPosition except: import player try: import chatm2g as chat except: import chat try: import m2netm2g as net except: import net try: import chrmgrm2g as chrmgr except: import chrmgr ########################### IMPORT LIBS ############### SHOW INFO ############### chat.AppendChat(7, '############ My first sccript ###########') chat.AppendChat(7, '############ 1. enjoy ###########') chat.AppendChat(7, '############ 2. xxxxxxxxxxxxxx ###########') chat.AppendChat(7, '############ 3. xxxxxxxxxxxx ###########') chat.AppendChat(7, '############ 4.xxxx ###########') class okno(ui.BoardWithTitleBar): def __init__(self): self.okno = ui.BoardWithTitleBar() self.okno.SetTitleName('First Windows') self.okno.SetSize(150, 150) self.okno.SetCenterPosition() self.okno.AddFlag("movable") self.okno.Show() self.buttonss() qqq = okno() qqq.Show() Link to comment Share on other sites More sharing options...
Forum Moderator VegaS™ 10290 Posted April 2, 2020 Forum Moderator Share Posted April 2, 2020 (edited) class okno(ui.BoardWithTitleBar): def __init__(self): You forgot to initialize the BoardWithTitleBar class: ui.BoardWithTitleBar.__init__(self) For adding a button you can use: ui.MakeButton(parent, x, y, tooltipText, path, up, over, down) On 4/2/2020 at 11:19 PM, NoisyNoise said: try: import playerm2g2 as player chr.GetPixelPosition = player.GetMainCharacterPosition except: import player try: import chatm2g as chat except: import chat try: import m2netm2g as net except: import net try: import chrmgrm2g as chrmgr except: import chrmgr Also for importing excepting modules you could do something better: for (moduleName, shortModuleName) in (('playerm2g2', 'player'), ('chatm2g', 'chat'), ('chrmgrm2g', 'chrmgr')): try: module = __import__(moduleName) except: module = __import__(shortModuleName) globals()[shortModuleName] = module So, this is the whole script: This is the hidden content, please Sign In or Sign Up Edited December 3, 2020 by VegaS™ 3 6 7 Check my GitHub Profile Click to find all the threads started by me [TOOL] Text file loader + JSON Link to comment Share on other sites More sharing options...
NoisyNoise 0 Posted April 2, 2020 Author Share Posted April 2, 2020 You are crazy genius. Your script is completely different than my. Do you recommend any tutorials for python? Thanks a lot! Link to comment Share on other sites More sharing options...
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now