Stefan 93 Posted September 30, 2015 Share Posted September 30, 2015 How to get value entered by player into editline? I want to save editline value as VALUE and then make something like this:self.HeaderLabe3.SetText(VALUE) Pls help Link to comment Share on other sites More sharing options...
Shang 370 Posted September 30, 2015 Share Posted September 30, 2015 self.HeaderLabe3.GetText() 1 Link to comment Share on other sites More sharing options...
Stefan 93 Posted September 30, 2015 Author Share Posted September 30, 2015 (edited) I want to make red label same as entered value in editbox, after I click run. Here is my code: import ui import dbg import os class Dialog1(ui.ThinBoard): def __init__(self): ui.ThinBoard.__init__(self) self.BuildWindow() def __del__(self): ui.ThinBoard.__del__(self) def BuildWindow(self): self.SetSize(600, 40) self.SetPosition(10, 40) self.AddFlag('float') self.comp = Component() self.HeaderLabe3 = self.comp.TextLine(self, '-----', 230, 9, self.comp.RGB(255, 0, 0)) self.Close = self.comp.Button(self, '', '', 575, 10, self.Close_func, 'd:/ymir work/ui/public/close_button_01.sub', 'd:/ymir work/ui/public/close_button_02.sub', 'd:/ymir work/ui/public/close_button_03.sub') self.EditLine1 = self.comp.EditLine(self, '', 70, 8, 61, 18, 6) self.Run = self.comp.Button(self, 'Run', '', 185, 8, self.Run_func, 'd:/ymir work/ui/public/small_button_01.sub', 'd:/ymir work/ui/public/small_button_02.sub', 'd:/ymir work/ui/public/small_button_03.sub') def Run_func(self): self.HeaderLabe3.SetText(self.EditLine1) def Close_func(self): self.Hide() def Close(self): self.Hide() class Component: def Button(self, parent, buttonName, tooltipText, x, y, func, UpVisual, OverVisual, DownVisual): button = ui.Button() button.SetParent(parent) button.SetPosition(x, y) button.SetUpVisual(UpVisual) button.SetOverVisual(OverVisual) button.SetDownVisual(DownVisual) button.SetText(buttonName) button.SetToolTipText(tooltipText) button.Show() button.SetEvent(func) return button def ToggleButton(self, parent, buttonName, tooltipText, x, y, funcUp, funcDown, UpVisual, OverVisual, DownVisual): button = ui.ToggleButton() button.SetParent(parent) button.SetPosition(x, y) button.SetUpVisual(UpVisual) button.SetOverVisual(OverVisual) button.SetDownVisual(DownVisual) button.SetText(buttonName) button.SetToolTipText(tooltipText) button.Show() button.SetToggleUpEvent(funcUp) button.SetToggleDownEvent(funcDown) return button def EditLine(self, parent, editlineText, x, y, width, heigh, max): SlotBar = ui.SlotBar() SlotBar.SetParent(parent) SlotBar.SetSize(width, heigh) SlotBar.SetPosition(x, y) SlotBar.Show() Value = ui.EditLine() Value.SetParent(SlotBar) Value.SetSize(width, heigh) Value.SetPosition(5, 1) Value.SetMax(max) Value.SetText(editlineText) Value.Show() return SlotBar, Value def TextLine(self, parent, textlineText, x, y, color): textline = ui.TextLine() textline.SetParent(parent) textline.SetPosition(x, y) if color != None: textline.SetFontColor(color[0], color[1], color[2]) textline.SetText(textlineText) textline.Show() return textline def RGB(self, r, g, b): return (r*255, g*255, b*255) def SliderBar(self, parent, sliderPos, func, x, y): Slider = ui.SliderBar() Slider.SetParent(parent) Slider.SetPosition(x, y) Slider.SetSliderPos(sliderPos / 100) Slider.Show() Slider.SetEvent(func) return Slider def ExpandedImage(self, parent, x, y, img): image = ui.ExpandedImageBox() image.SetParent(parent) image.SetPosition(x, y) image.LoadImage(img) image.Show() return image def ComboBox(self, parent, text, x, y, width): combo = ui.ComboBox() combo.SetParent(parent) combo.SetPosition(x, y) combo.SetSize(width, 15) combo.SetCurrentItem(text) combo.Show() return combo def ThinBoard(self, parent, moveable, x, y, width, heigh, center): thin = ui.ThinBoard() if parent != None: thin.SetParent(parent) if moveable == TRUE: thin.AddFlag('movable') thin.AddFlag('float') thin.SetSize(width, heigh) thin.SetPosition(x, y) if center == TRUE: thin.SetCenterPosition() thin.Show() return thin Dialog1().Show() Edited August 24, 2022 by Metin2 Dev Core X - External 2 Internal Link to comment Share on other sites More sharing options...
Premium masodikbela 1359 Posted September 30, 2015 Premium Share Posted September 30, 2015 def Run_func(self): self.HeaderLabe3.SetText(self.EditLine1.GetText()) 1 The one and only UI programming guideline Link to comment Share on other sites More sharing options...
Stefan 93 Posted September 30, 2015 Author Share Posted September 30, 2015 def Run_func(self): self.HeaderLabe3.SetText(self.EditLine1.GetText()) 0930 21:33:11104 :: self.HeaderLabe3.SetText(self.EditLine1.GetText()) 0930 21:33:11104 :: AttributeError0930 21:33:11104 :: : 0930 21:33:11104 :: 'tuple' object has no attribute 'GetText' Link to comment Share on other sites More sharing options...
Premium masodikbela 1359 Posted September 30, 2015 Premium Share Posted September 30, 2015 Then: def Run_func(self): self.HeaderLabe3.SetText(self.EditLine1[1].GetText()) or self.EditLine1_slotbar, self.EditLine1 = self.comp.EditLine(self, '', 70, 8, 61, 18, 6) and then the function: def Run_func(self): self.HeaderLabe3.SetText(self.EditLine1.GetText()) 1 The one and only UI programming guideline Link to comment Share on other sites More sharing options...
Shang 370 Posted September 30, 2015 Share Posted September 30, 2015 (edited) def Run_func(self): self.HeaderLabe3.SetText(self.EditLine1.GetText()) 0930 21:33:11104 :: self.HeaderLabe3.SetText(self.EditLine1.GetText()) 0930 21:33:11104 :: AttributeError0930 21:33:11104 :: : 0930 21:33:11104 :: 'tuple' object has no attribute 'GetText' This happens 'cause your function returns more than 1 value. Try this: self.EditLine[1].GetText() Edited September 30, 2015 by Shang 1 Link to comment Share on other sites More sharing options...
Stefan 93 Posted September 30, 2015 Author Share Posted September 30, 2015 Then: def Run_func(self): self.HeaderLabe3.SetText(str(self.EditLine1.GetText())) Same error. def Run_func(self): self.HeaderLabe3.SetText(self.EditLine1.GetText()) 0930 21:33:11104 :: self.HeaderLabe3.SetText(self.EditLine1.GetText()) 0930 21:33:11104 :: AttributeError0930 21:33:11104 :: : 0930 21:33:11104 :: 'tuple' object has no attribute 'GetText' This happens 'cause your function returns more than 1 value. Try this: self.HeaderLabe3[1].GetText() self.HeaderLabe3.SetText(self.EditLine1[1].GetText()) works fine! Thx guys for help 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