Jump to content

[PYTH]Trying to add buttons to gui.


Recommended Posts

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

  • Forum Moderator
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

 

Edited by VegaS™
  • Metin2 Dev 3
  • Good 6
  • Love 7
Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now

Announcements



×
×
  • Create New...

Important Information

Terms of Use / Privacy Policy / Guidelines / We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.