Python

Indította TTMaster112, 2017-03-02, 16:13:11

2017-03-02, 16:13:11 Utolsó szerkesztés: 2017-03-02, 16:53:45 Szerző: [MOD]Linos
Sziasztok,
Ui py ba van ez a új fuksön
class BoardWithTitleBarAndSelect(Board):
Ha így inditom a klienst "board is not defined"
viszont a ittvan szóval megvan csak valamiért mégse
elif Type == "board":
parent.Children[Index] = Board()
parent.Children[Index].SetParent(parent)
self.LoadElementBoard(parent.Children[Index], ElementValue, parent)

Ha kitörlöm a (board) ot
[code]class BoardWithTitleBarAndSelect():[/code]
unbound method __init__() must be called with Board instance as first argument (got BoardWithTitleBarAndSelect instance instead)
Már teljes mértékbe nem értem mi a baj O.o

IdézHa így inditom a klienst "board is not defined"

hiányzik a board definícója

Elméletileg ez hívja meg
elif Type == "board":
parent.Children[Index] = Board()
parent.Children[Index].SetParent(parent)
self.LoadElementBoard(parent.Children[Index], ElementValue, parent)

def CloseTargetBoard(self):
self.targetBoard.Close()


ilyen definicióra gondolok

2017-03-02, 17:46:48 #4 Utolsó szerkesztés: 2017-03-02, 19:16:01 Szerző: TTMaster112
## Board
def LoadElementBoard(self, window, value, parentWindow):

if False == self.CheckKeyList(value["name"], value, self.BOARD_KEY_LIST):
return False

window.SetSize(int(value["width"]), int(value["height"]))
self.LoadDefaultData(window, value, parentWindow)

return True


Üzenet összefésülés: 2017-03-02, 19:16:01

De ugyan úgy not defined :-\ van benne egy UI py teljesen azonos a tartalma kivéve 1-2 acce/switch boni dolgot és azzal megy  ??? tabolás mind2 be ugyan úgy jó :)

2017-03-03, 21:44:26 #5 Utolsó szerkesztés: 2017-03-03, 21:46:21 Szerző: Pisti95
Idézetet írta: TTMaster112 Dátum 2017-03-02, 16:13:11
"board is not defined"

Azért tegyük tisztába, és teljes sysser-t másold ide. Igaz úgy is ez a teljes sora (global name 'board' is not defined), vagyis nincs definiálva.


ui.py

Rákeresel erre:

class ThinBoard(Window):



Fölé másolod ezt a 2 osztályt:

class Board(Window):

CORNER_WIDTH = 32
CORNER_HEIGHT = 32
LINE_WIDTH = 128
LINE_HEIGHT = 128

LT = 0
LB = 1
RT = 2
RB = 3
L = 0
R = 1
T = 2
B = 3

def __init__(self):
Window.__init__(self)

self.MakeBoard("d:/ymir work/ui/pattern/Board_Corner_", "d:/ymir work/ui/pattern/Board_Line_")
self.MakeBase()

def MakeBoard(self, cornerPath, linePath):

CornerFileNames = [ cornerPath+dir+".tga" for dir in ("LeftTop", "LeftBottom", "RightTop", "RightBottom", ) ]
LineFileNames = [ linePath+dir+".tga" for dir in ("Left", "Right", "Top", "Bottom", ) ]
"""
CornerFileNames = (
"d:/ymir work/ui/pattern/Board_Corner_LeftTop.tga",
"d:/ymir work/ui/pattern/Board_Corner_LeftBottom.tga",
"d:/ymir work/ui/pattern/Board_Corner_RightTop.tga",
"d:/ymir work/ui/pattern/Board_Corner_RightBottom.tga",
)
LineFileNames = (
"d:/ymir work/ui/pattern/Board_Line_Left.tga",
"d:/ymir work/ui/pattern/Board_Line_Right.tga",
"d:/ymir work/ui/pattern/Board_Line_Top.tga",
"d:/ymir work/ui/pattern/Board_Line_Bottom.tga",
)
"""

self.Corners = []
for fileName in CornerFileNames:
Corner = ExpandedImageBox()
Corner.AddFlag("not_pick")
Corner.LoadImage(fileName)
Corner.SetParent(self)
Corner.SetPosition(0, 0)
Corner.Show()
self.Corners.append(Corner)

self.Lines = []
for fileName in LineFileNames:
Line = ExpandedImageBox()
Line.AddFlag("not_pick")
Line.LoadImage(fileName)
Line.SetParent(self)
Line.SetPosition(0, 0)
Line.Show()
self.Lines.append(Line)

self.Lines[self.L].SetPosition(0, self.CORNER_HEIGHT)
self.Lines[self.T].SetPosition(self.CORNER_WIDTH, 0)

def MakeBase(self):
self.Base = ExpandedImageBox()
self.Base.AddFlag("not_pick")
self.Base.LoadImage("d:/ymir work/ui/pattern/Board_Base.tga")
self.Base.SetParent(self)
self.Base.SetPosition(self.CORNER_WIDTH, self.CORNER_HEIGHT)
self.Base.Show()

def __del__(self):
Window.__del__(self)

def SetSize(self, width, height):

width = max(self.CORNER_WIDTH*2, width)
height = max(self.CORNER_HEIGHT*2, height)
Window.SetSize(self, width, height)

self.Corners[self.LB].SetPosition(0, height - self.CORNER_HEIGHT)
self.Corners[self.RT].SetPosition(width - self.CORNER_WIDTH, 0)
self.Corners[self.RB].SetPosition(width - self.CORNER_WIDTH, height - self.CORNER_HEIGHT)
self.Lines[self.R].SetPosition(width - self.CORNER_WIDTH, self.CORNER_HEIGHT)
self.Lines[self.B].SetPosition(self.CORNER_HEIGHT, height - self.CORNER_HEIGHT)

verticalShowingPercentage = float((height - self.CORNER_HEIGHT*2) - self.LINE_HEIGHT) / self.LINE_HEIGHT
horizontalShowingPercentage = float((width - self.CORNER_WIDTH*2) - self.LINE_WIDTH) / self.LINE_WIDTH
self.Lines[self.L].SetRenderingRect(0, 0, 0, verticalShowingPercentage)
self.Lines[self.R].SetRenderingRect(0, 0, 0, verticalShowingPercentage)
self.Lines[self.T].SetRenderingRect(0, 0, horizontalShowingPercentage, 0)
self.Lines[self.B].SetRenderingRect(0, 0, horizontalShowingPercentage, 0)

if self.Base:
self.Base.SetRenderingRect(0, 0, horizontalShowingPercentage, verticalShowingPercentage)

class BoardWithTitleBar(Board):
def __init__(self):
Board.__init__(self)

titleBar = TitleBar()
titleBar.SetParent(self)
titleBar.MakeTitleBar(0, "red")
titleBar.SetPosition(8, 7)
titleBar.Show()

titleName = TextLine()
titleName.SetParent(titleBar)
titleName.SetPosition(0, 4)
titleName.SetWindowHorizontalAlignCenter()
titleName.SetHorizontalAlignCenter()
titleName.Show()

self.titleBar = titleBar
self.titleName = titleName

self.SetCloseEvent(self.Hide)

def __del__(self):
Board.__del__(self)
self.titleBar = None
self.titleName = None

def SetSize(self, width, height):
self.titleBar.SetWidth(width - 15)
#self.pickRestrictWindow.SetSize(width, height - 30)
Board.SetSize(self, width, height)
self.titleName.UpdateRect()

def SetTitleColor(self, color):
self.titleName.SetPackedFontColor(color)

def SetTitleName(self, name):
self.titleName.SetText(name)

def SetCloseEvent(self, event):
self.titleBar.SetCloseEvent(event)



(Lényegében az első osztály elég lenne alap esetben, de jobb ha mindkettőt leellenőrzöd a sorrendjét.)