当前位置: 首页>>代码示例>>Python>>正文


Python TextBox.setWidth方法代码示例

本文整理汇总了Python中pyjamas.ui.TextBox.TextBox.setWidth方法的典型用法代码示例。如果您正苦于以下问题:Python TextBox.setWidth方法的具体用法?Python TextBox.setWidth怎么用?Python TextBox.setWidth使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在pyjamas.ui.TextBox.TextBox的用法示例。


在下文中一共展示了TextBox.setWidth方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: editMovieButton_Click

# 需要导入模块: from pyjamas.ui.TextBox import TextBox [as 别名]
# 或者: from pyjamas.ui.TextBox.TextBox import setWidth [as 别名]
		def editMovieButton_Click(sender):   		
    	    # Add textboxes and listbox
			editMovieButton.setVisible(False)
			cancelButton.setVisible(True)
			saveButton.setVisible(True)
			editCategory = TextBox()
			editName = TextBox()
			editRating = ListBox(False)
			for i in range(self.MAX_RATING + 1):
				editRating.addItem(str(i))
    		
    		# Variable width textboxes
			catlen = len(movie.category)
			namelen = len(movie.name)    		
			if (catlen > 8):
				editCategory.setWidth(str(catlen*10) + "px")
			else:
				editCategory.setWidth("80px")
			if (namelen > 8):
				editName.setWidth(str(namelen*10) + "px")
			else:
				editName.setWidth("80px")
    		
			self.moviesFlexTable.setWidget(row, 1, editCategory)
			self.moviesFlexTable.setWidget(row, 2, editName)
			self.moviesFlexTable.setWidget(row, 3, editRating)
			editCategory.setText(movie.category)
			editName.setText(movie.name)
			editRating.setSelectedIndex(movie.rating)			
开发者ID:FloorLamp,项目名称:CS3300-HW4,代码行数:31,代码来源:MovieRatings.py

示例2: createStatesPanel

# 需要导入模块: from pyjamas.ui.TextBox import TextBox [as 别名]
# 或者: from pyjamas.ui.TextBox.TextBox import setWidth [as 别名]
	def createStatesPanel(self):
		vertPanel=VerticalPanel()
		vertPanel.setSpacing(10)
		
		selectionNames = (["Main Control", "Masks", "Trims"])	
		registerSelection = VerticalPanel()
		
		for name in selectionNames :
			checkBox = CheckBox(name)
			checkBox.setTitle(name)
			self.stateValueEntries[name]=checkBox
			registerSelection.add(checkBox)
		
		#Tidy up 
		loadPanel = HorizontalPanel()
		loadFileTextBox = TextBox()
		loadFileTextBox.setText("MyI2cCfg")
		loadFileTextBox.setWidth(80)
		self.loadFileName = loadFileTextBox
		loadPanel.add(loadFileTextBox)
		self.load = Button("Load",getattr(self,"onChange")) #overrides default and sends it to onChange
		loadPanel.add(self.load)
		self.load.setEnabled(False)
		
		savePanel = HorizontalPanel()
		saveFileTextBox = TextBox()
		saveFileTextBox.setText("MyI2cCfg")
		saveFileTextBox.setWidth(80)
		self.saveFileName = saveFileTextBox
		savePanel.add(saveFileTextBox)
		self.save = Button("Save", getattr(self,"onChange"))
		savePanel.add(self.save)
		self.save.setEnabled(False)
		
		self.returnStatement = Label()
		
		vertPanel.add(registerSelection)
		vertPanel.add(loadPanel)
		vertPanel.add(savePanel)
		vertPanel.add(self.returnStatement)
		
		return vertPanel
开发者ID:BristolHEP-CBC-Testing,项目名称:cbcanalysis,代码行数:44,代码来源:I2CPanel.py

示例3: createControlPanel

# 需要导入模块: from pyjamas.ui.TextBox import TextBox [as 别名]
# 或者: from pyjamas.ui.TextBox.TextBox import setWidth [as 别名]
	def createControlPanel(self, controlNames):
		flowPanel=FlowPanel()
		newLabels=[]
		for buttonName in controlNames:
			newPanel=HorizontalPanel()
			newLabels.append(Label(buttonName))
			newPanel.add(newLabels[-1])
			newTextBox=TextBox()
			newTextBox.setEnabled(True)
			newTextBox.setWidth(80)
			newPanel.add(newTextBox)	
			if buttonName=="RangeLo" :
				newTextBox.setText("100") # Default values
				self.rangeLowBox=newTextBox
			elif buttonName=="RangeHi" :
				newTextBox.setText("150")
				self.rangeHighBox=newTextBox
			elif buttonName=="Steps" :
				newTextBox.setText("1")
				self.stepSizeBox=newTextBox
			elif buttonName=="FileName": newTextBox.setText("TestRun.png")
			
			#newTextBox.addChangeListener(self)
			newTextBox.setTitle(buttonName)
			
			self.controlValueEntries[buttonName]=newTextBox	
			
			flowPanel.add(newPanel)
		

		# Set all of the widths of the labels to be the same, so that the boxes line up
		maxWidth=0
		for label in newLabels :
			# This doesn't work for some reason
			#if label.getWidth() > maxWidth : maxWidth=label.getWidth()
			if len(label.getText())*9 > maxWidth : maxWidth=len(label.getText())*9
		for label in newLabels :
			label.setWidth(maxWidth)

		return flowPanel
开发者ID:BristolHEP-CBC-Testing,项目名称:cbcanalysis,代码行数:42,代码来源:SCurveRunPanel.py

示例4: createRegisterPanel

# 需要导入模块: from pyjamas.ui.TextBox import TextBox [as 别名]
# 或者: from pyjamas.ui.TextBox.TextBox import setWidth [as 别名]
	def createRegisterPanel( self, registerNames ) :
		"""
		Creates panels and buttons for everything given in registerNames, and returns the main panel.
		"""
		flowPanel=FlowPanel()
		for buttonName in registerNames :
			newPanel=HorizontalPanel()
			label=Label(buttonName)
			newPanel.add( label )
			newTextBox=TextBox()
			newTextBox.setEnabled(False)
			newTextBox.setWidth(80)
			statusBox=TextBox()
			statusBox.setEnabled(False)
			statusBox.setWidth(30)
			newPanel.add(newTextBox)
			newPanel.add(statusBox)
			newPanel.setCellHorizontalAlignment( newTextBox, HasHorizontalAlignment.ALIGN_RIGHT )
			newPanel.setCellHorizontalAlignment( statusBox, HasHorizontalAlignment.ALIGN_RIGHT )
			newPanel.setCellWidth( statusBox, "20px" )
			newPanel.setWidth("100%")
			#newPanel.setStyleName("areaStyle");
			#newPanel.setBorderWidth(5);
			
			newTextBox.setText("select chip...")
			newTextBox.addChangeListener(self)
			newTextBox.setTitle(buttonName) # This isn't displayed, but it's useful to have stored
			
			self.i2cValueEntries[buttonName]=newTextBox	
			
			self.statusValueEntries[buttonName]=statusBox
			statusBox.setTitle(buttonName)
			statusBox.setText("...")
			
			flowPanel.add(newPanel)


		return flowPanel
开发者ID:BristolHEP-CBC-Testing,项目名称:cbcanalysis,代码行数:40,代码来源:I2CPanel.py

示例5: createTextBox

# 需要导入模块: from pyjamas.ui.TextBox import TextBox [as 别名]
# 或者: from pyjamas.ui.TextBox.TextBox import setWidth [as 别名]
 def createTextBox(self, startVal):
     res = TextBox()
     res.setWidth("35px")
     res.setText(str(startVal))
     return res
开发者ID:Afey,项目名称:pyjs,代码行数:7,代码来源:SelectionTest.py

示例6: EventLinkPopup

# 需要导入模块: from pyjamas.ui.TextBox import TextBox [as 别名]
# 或者: from pyjamas.ui.TextBox.TextBox import setWidth [as 别名]
class EventLinkPopup(PopupPanel):

    def __init__(self, editor):
        PopupPanel.__init__(self, glass=True)

        self.m_origAnchorStart = None
        self.m_origAnchorEnd = None
        self.m_origTargetText = ""
        self.m_editor = editor

        vpanel = VerticalPanel()
        vpanel.setWidth("350px")

        self.m_webPageText = TextBox()
        self.m_webPageText.setText("http:#")
        self.m_webPageText.setWidth("320px")

        vpanel.add(self.m_webPageText)

        lbl = Label("Display:")

        self.m_targetText = TextBox()
        self.m_targetText.setWidth("100%")

        lpanel = HorizontalPanel()
        lpanel.add(lbl)
        lpanel.add(self.m_targetText)

        vpanel.add(lpanel)

        self.m_fillOutCB = CheckBox("Change entire link")
        self.m_fillOutCB.setVisible(False)
        self.m_fillOutCB.addClickListener(self)
        vpanel.add(self.m_fillOutCB)

        self.m_okBut = Button("Ok", self)
        self.m_okBut.addStyleName("float-left")

        self.m_cancelBut = Button("Cancel", self)
        self.m_cancelBut.addStyleName("float-left")

        hpanel = HorizontalPanel()
        hpanel.add(self.m_okBut)
        hpanel.add(self.m_cancelBut)

        vpanel.add(hpanel)

        self.add(vpanel)
        self.setStyleName("gwt-DialogBox")

    def refresh(self):
        try:
            self.m_editor.getSelection()
            self.m_range = self.m_editor.getRange()
            if self.m_range is None:
                return False
            else:
                self.m_selTexts = self.m_range.getSelectedTextElements()
                if self.m_selTexts is None:
                    return False
                else:
                    self.m_origTargetText = self.m_range.getText()
                    self.m_targetText.setText(self.m_origTargetText)

                    anchor = self.getAnchor(self.m_selTexts)
                    if anchor is not None:
                        href = anchor.getHref().strip()
                        if href:
                            self.m_webPageText.setText(href)

                        self.m_origAnchorStart = self.getAnchorLimit(
                                self.m_range.getStartPoint().getTextNode(),
                                anchor, False)
                        self.m_origAnchorEnd = self.getAnchorLimit(
                                self.m_range.getStartPoint().getTextNode(),
                                anchor, True)

                        if self.m_range.getStartPoint().equals(self.m_origAnchorStart)  and  self.m_range.getStartPoint().equals(self.m_origAnchorEnd):
                            self.m_origAnchorStart = None
                            self.m_origAnchorEnd = None

                        else:
                            self.m_fillOutCB.setVisible(True)
                            self.m_fillOutCB.setValue(True)

                            self.m_origTargetText = self.fetchStringFromTexts(
                                self.m_origAnchorStart, self.m_origAnchorEnd)
                            self.m_targetText.setText(self.m_origTargetText)





        except:
            print "exception"
            traceback.print_exc()
            return False

        return True

#.........这里部分代码省略.........
开发者ID:Afey,项目名称:pyjs,代码行数:103,代码来源:RichTextToolbar.py

示例7: Spinner

# 需要导入模块: from pyjamas.ui.TextBox import TextBox [as 别名]
# 或者: from pyjamas.ui.TextBox.TextBox import setWidth [as 别名]
class Spinner(HorizontalPanel):
    CHAR_WIDTH = 15
    def __init__(self, minvalue=0, maxvalue=100, startvalue=10, interval=1, buttonStyleName=None, decrText='<',
                 incrText='>', **kwargs):
        HorizontalPanel.__init__(self, **kwargs)
        self.minvalue = minvalue
        self.maxvalue = maxvalue
        self.interval = interval
        self.changeListeners = []

        self.lessButton = Button(decrText, listener=self._onArrowClick, StyleName=buttonStyleName)
        self.add(self.lessButton)
        self.textbox = TextBox()
        self.textbox.addInputListener(self._onTextboxInput)
        self.add(self.textbox)

        self.moreButton = Button(incrText, listener=self._onArrowClick, StyleName=buttonStyleName)
        self.add(self.moreButton)

        self.value = startvalue + 1
        self.setValue(startvalue)
        return
    def _resizeTextbox(self):
        width = max(2, len(self.textbox.getText())) * self.CHAR_WIDTH
        if self.textbox.getWidth() != width:
            self.textbox.setWidth(width)
    def _onArrowClick(self, sender):
        if sender == self.lessButton:
            incr = -1 * self.interval
        elif sender == self.moreButton:
            incr = self.interval
        else:
            raise NotImplementedError()
        val = self.getValue() + incr
        self.setValue(val)
    def _onTextboxInput(self, sender):
        text = sender.getText()
        try:
            val = int(text)
        except Exception:
            return
        self.setValue(val)
        return
    def addOnChangeListener(self, listener):
        self.changeListeners.append(listener)
    def removeOnChangeListener(self, listener):
        self.changeListeners.remove(listener)
    def getValue(self):
        return self.value
    def setValue(self, value):
        fixedval = min(self.maxvalue, value)
        fixedval = max(self.minvalue, fixedval)
        if fixedval == self.value:
            return
        self.value = fixedval
        self.textbox.setText(str(self.value))
        self._resizeTextbox()
        self.raiseOnChanged()
    def raiseOnChanged(self):
        for c in self.changeListeners:
            c(self.value)
开发者ID:satyam07,项目名称:taoggregator,代码行数:63,代码来源:commoncontrols.py


注:本文中的pyjamas.ui.TextBox.TextBox.setWidth方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。