Jump to content
×
×
  • Create New...
  • 0

[Q] How to get value from editline?


Stefan

Question

7 answers to this question

Recommended Posts

  • 0

qdh5b7.jpg

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()

 

-

Link to comment
Share on other sites

  • 0
	def Run_func(self):
		self.HeaderLabe3.SetText(self.EditLine1.GetText())

0930 21:33:11104 :: self.HeaderLabe3.SetText(self.EditLine1.GetText())

0930 21:33:11104 :: AttributeError
0930 21:33:11104 :: : 
0930 21:33:11104 :: 'tuple' object has no attribute 'GetText'

-

Link to comment
Share on other sites

  • 0
  • Premium

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())
  • Love 1

The one and only UI programming guideline

Link to comment
Share on other sites

  • 0
	def Run_func(self):
		self.HeaderLabe3.SetText(self.EditLine1.GetText())

 

0930 21:33:11104 :: self.HeaderLabe3.SetText(self.EditLine1.GetText())

0930 21:33:11104 :: AttributeError
0930 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 by Shang
  • Love 1
Link to comment
Share on other sites

  • 0

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 :: AttributeError
0930 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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Activity

    1. 4

      Ludus2: a metin2-like browser game

    2. 6
    3. 9

      Help in implementing a switch bot

    4. 0

      Special Inventory System Can't Sell To Npc's

    5. 0

      ROV2.GLOBAL | International | Server start 14.05.2022

    6. 75

      Services - System Ard [C ++ / Python / Lua]

    7. 76

      Chatting Window Renewal (Mini Version)

    8. 2

      ItemShop GM ZONE TAB

  • Recently Browsing

    • No registered users viewing this page.

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.