예제 #1
0
class EditPanel(AbsolutePanel):

    def __init__(self, key, title, content):
        AbsolutePanel.__init__(self)
        self.edit_header = Label("Edit a Post", StyleName="header_label")
        self.edit_title_label = Label("Title:")
        self.edit_title = TextBox()
        self.edit_title.setMaxLength(255)
        self.edit_content = TextArea()
        self.edit_content.setVisibleLines(2)
        self.edit_button = Button("Save")
        self.edit_cancel_button = Button("Cancel")
        self.edit_hidden_key = Hidden()
        self.error_message_label = Label("", StyleName="error_message_label")
        edit_contents = VerticalPanel(StyleName="Contents", Spacing=4)
        edit_contents.add(self.edit_header)
        edit_contents.add(self.edit_title_label)
        edit_contents.add(self.edit_title)
        edit_contents.add(self.edit_content)
        edit_contents.add(self.edit_button)
        edit_contents.add(self.edit_cancel_button)
        edit_contents.add(self.error_message_label)
        edit_contents.add(self.edit_hidden_key)
        self.edit_dialog = DialogBox(glass=True)
        self.edit_dialog.setHTML('<b>Blog Post Form</b>')
        self.edit_dialog.setWidget(edit_contents)
        left = (Window.getClientWidth() - 900) / 2 + Window.getScrollLeft()
        top = (Window.getClientHeight() - 600) / 2 + Window.getScrollTop()
        self.edit_dialog.setPopupPosition(left, top)
        self.edit_dialog.hide()

    def clear_edit_panel(self):
        self.edit_title.setText("")
        self.edit_content.setText("")
        self.error_message_label.setText("")
예제 #2
0
파일: cancel.py 프로젝트: fluidinfo/Tickery
class Cancel(HorizontalPanel):
    def __init__(self):
        HorizontalPanel.__init__(self, Spacing=4)
        self.add(Label('Cancel:', StyleName='section'))
        self.name = TextBox()
        self.name.setMaxLength(18)
        self.name.setVisibleLength(18)
        self.add(self.name)
        self.cancel = Button('Do it', self)
        self.add(self.cancel)
        self.err = Label()
        self.add(self.err)

    def onClick(self, sender):
        self.err.setText('')
        name = self.name.getText().strip()
        if name == '':
            return
        else:
            self.cancel.setEnabled(False)
            remote = server.AdminService()
            id = remote.cancel(name, self)
            if id < 0:
                self.err.setText('oops: could not cancel')

    def onRemoteResponse(self, result, request_info):
        self.cancel.setEnabled(True)
        self.name.setText('')

    def onRemoteError(self, code, message, request_info):
        self.cancel.setEnabled(True)
        self.err.setText('Could not cancel: ' + message['data']['message'])
예제 #3
0
    def __init__(self):
        SimplePanel.__init__(self)

        field = TextBox()
        field.setVisibleLength(20)
        field.setMaxLength(10)

        self.add(field)
예제 #4
0
파일: textBox.py 프로젝트: Afey/pyjs
    def __init__(self):
        SimplePanel.__init__(self)

        field = TextBox()
        field.setVisibleLength(20)
        field.setMaxLength(10)

        self.add(field)
예제 #5
0
class DatePicker(HorizontalPanel):

    time = None
    dateBox = None

    def __init__(self):
        try:
            HorizontalPanel.__init__(self)
            self.time = time.time()

            prevDayBtn = Button(" < ", self.onPrevDay)
            nextDayBtn = Button(" > ", self.onNextDay)
            prevWeekBtn = Button(" << ", self.onPrevWeek)
            nextWeekBtn = Button(" >> ", self.onNextWeek)
            self.dateBox = TextBox()
            self.dateBox.setMaxLength(10)
            self.dateBox.setVisibleLength(10)

            self.add(prevWeekBtn)
            self.add(prevDayBtn)
            self.add(self.dateBox)
            self.add(nextDayBtn)
            self.add(nextWeekBtn)
        except:
            raise

    def onPrevDay(self, sender):
        self.mediator.sendNotification(Notification.PREV_DAY)

    def onNextDay(self, sender):
        self.mediator.sendNotification(Notification.NEXT_DAY)

    def onPrevWeek(self, sender):
        self.mediator.sendNotification(Notification.PREV_WEEK)

    def onNextWeek(self, sender):
        self.mediator.sendNotification(Notification.NEXT_WEEK)

    def displayDay(self):
        self.dateBox.setText(time.strftime("%d/%m/%Y", time.localtime(self.time)))
        date = time.strftime("%Y%m%d", time.localtime(self.time))
        self.mediator.sendNotification(Notification.DATE_SELECTED, date)

    def prevDay(self):
        self.time -= 86400
        self.displayDay()

    def nextDay(self):
        self.time += 86400
        self.displayDay()

    def prevWeek(self):
        self.time -= 7*86400
        self.displayDay()

    def nextWeek(self):
        self.time += 7*86400
        self.displayDay()
예제 #6
0
class PopupNewVar(Popup):
    def __init__(self, okClick, cancelClick):
        Popup.__init__(self, '<b>Nova Vari&aacute;vel</b>', okClick,
                       cancelClick, CONFIRM_CANCEL)

    def draw(self):
        Popup.draw(self)

        namePanel = HorizontalPanel()
        namePanel.add(Label(_('Name') + ':'))
        self.textBox = TextBox()
        self.textBox.setMaxLength(15)
        self.textBox.setStyleAttribute('marginLeft', 10)
        namePanel.add(self.textBox)
        self.center.add(namePanel)

        self.choose = ChooseTypeVarPanel()
        self.center.add(self.choose)

        self.textBox.addInputListener(self)

        self.message = Element(Element=DOM.createDiv())
        self.message.add(Widget(Element=DOM.createDiv(),
                                StyleName='not_image'))
        self.message.add(
            Label(text=_('Name already used'),
                  wordWrap=False,
                  StyleName='not_message'))

        self.onInput()

    def onInput(self, sender):
        if self.textBox.getText().count(' ') == len(self.textBox.getText()):
            self.okButton.addStyleName('disabled')
            self.south.remove(self.message)
        elif self.textBox.getText() in vars or self.textBox.getText(
        ) in createdBlocks:
            self.okButton.addStyleName('disabled')
            self.south.add(self.message)
        else:
            self.okButton.removeStyleName('disabled')
            self.south.remove(self.message)

    def myOkClick(self):
        if 'disabled' not in self.okButton.getStyleName():
            Popup.myOkClick(self)
            self.okClick(self.textBox.getText(), self.choose.selectedType)

    def myCancelClick(self):
        Popup.myCancelClick(self)
        if self.cancelClick is not None: self.cancelClick()

    def show(self):
        Popup.show(self)
        self.textBox.setFocus(True)
예제 #7
0
class DatePicker(HorizontalPanel):

    time = None
    dateBox = None

    def __init__(self):
        try:
            HorizontalPanel.__init__(self)
            self.time = time.time()
            self.date = None

            self.prevDayBtn = Button(" < ", self.onPrevDay)
            self.nextDayBtn = Button(" > ", self.onNextDay)
            self.prevWeekBtn = Button(" << ", self.onPrevWeek)
            self.nextWeekBtn = Button(" >> ", self.onNextWeek)
            self.dateBox = TextBox()
            self.dateBox.setMaxLength(10)
            self.dateBox.setVisibleLength(10)

            self.add(self.prevWeekBtn)
            self.add(self.prevDayBtn)
            self.add(self.dateBox)
            self.add(self.nextDayBtn)
            self.add(self.nextWeekBtn)
        except:
            raise

    def onPrevDay(self, sender):
        self.time -= 86400

    def onNextDay(self, sender):
        self.time += 86400

    def onPrevWeek(self, sender):
        self.time -= 7 * 86400

    def onNextWeek(self, sender):
        self.time += 7 * 86400

    def displayDay(self):
        self.dateBox.setText(
            time.strftime("%d/%m/%Y", time.localtime(self.time)))
        self.date = time.strftime("%Y%m%d", time.localtime(self.time))
예제 #8
0
class DatePicker(HorizontalPanel):

    time = None
    dateBox = None

    def __init__(self):
        try:
            HorizontalPanel.__init__(self)
            self.time = time.time()
            self.date = None

            self.prevDayBtn = Button(" < ", self.onPrevDay)
            self.nextDayBtn = Button(" > ", self.onNextDay)
            self.prevWeekBtn = Button(" << ", self.onPrevWeek)
            self.nextWeekBtn = Button(" >> ", self.onNextWeek)
            self.dateBox = TextBox()
            self.dateBox.setMaxLength(10)
            self.dateBox.setVisibleLength(10)

            self.add(self.prevWeekBtn)
            self.add(self.prevDayBtn)
            self.add(self.dateBox)
            self.add(self.nextDayBtn)
            self.add(self.nextWeekBtn)
        except:
            raise

    def onPrevDay(self, sender):
        self.time -= 86400

    def onNextDay(self, sender):
        self.time += 86400

    def onPrevWeek(self, sender):
        self.time -= 7*86400

    def onNextWeek(self, sender):
        self.time += 7*86400

    def displayDay(self):
        self.dateBox.setText(time.strftime("%d/%m/%Y", time.localtime(self.time)))
        self.date = time.strftime("%Y%m%d", time.localtime(self.time))
예제 #9
0
 def addRow(self, timeVO=None):
     self.rows += 1
     col = -1
     for name, maxLength, visibleLength in self.columns:
         col += 1
         textBox = TextBox()
         textBox.setText("")
         textBox.col = col
         textBox.row = self.rows
         textBox.addChangeListener(self.checkValid)
         textBox.addKeyboardListener(self)
         textBox.addFocusListener(self)
         textBox.setName(name)
         if not maxLength is None:
             textBox.setMaxLength(maxLength)
         if not visibleLength is None:
             textBox.setVisibleLength(visibleLength)
         self.setWidget(self.rows, col, textBox)
     if not timeVO is None:
         self.setRow(self.rows, timeVO)
예제 #10
0
파일: TimeGrid.py 프로젝트: Afey/pyjs
 def addRow(self, timeVO = None):
     self.rows += 1
     col = -1
     for name, maxLength, visibleLength in self.columns:
         col += 1
         textBox = TextBox()
         textBox.setText("")
         textBox.col = col
         textBox.row = self.rows
         textBox.addChangeListener(self.checkValid)
         textBox.addKeyboardListener(self)
         textBox.addFocusListener(self)
         textBox.setName(name)
         if not maxLength is None:
             textBox.setMaxLength(maxLength)
         if not visibleLength is None:
             textBox.setVisibleLength(visibleLength)
         self.setWidget(self.rows, col, textBox)
     if not timeVO is None:
         self.setRow(self.rows, timeVO)
예제 #11
0
파일: results.py 프로젝트: jdunck/Tickery
class ResultsLimit(HorizontalPanel):
    def __init__(self):
        HorizontalPanel.__init__(self, Spacing=4)
        self.add(Label('Results limit:', StyleName='section'))
        self.value = Label()
        self.add(self.value)
        self.newValue = TextBox()
        self.newValue.setMaxLength(5)
        self.newValue.setVisibleLength(5)
        self.add(self.newValue)
        self.update = Button('Update', ResultsUpdate(self))
        self.add(self.update)
        displayer = ResultsDisplay(self)
        self.refresh = Button('Refresh', displayer, StyleName='refresh')
        self.add(self.refresh)
        self.err = Label()
        self.add(self.err)
        remote = server.AdminService()
        id = remote.getResultsLimit(displayer)
        if id < 0:
            self.err.setText('oops: could not call getResultsLimit')
예제 #12
0
class Application:
	def __init__(self):
		#set some vars
		self.title = "last.fm"

		#this is where we build the ui
		self.statusPanel = VerticalPanel()
		self.statusPanel.setID('status_panel')

		#make a few Labels to hold station, artist, track, album info
		self.stationLabel = Label()
		self.artistLabel = Label()
		self.trackLabel = Label()
		self.albumLabel = Label()
		self.timeLabel = Label()
		self.infoTable = FlexTable()
		i=0
		self.stationLabel = Label()
		self.infoTable.setWidget(i,0,Label("Station:") )
		self.infoTable.setWidget(i,1,self.stationLabel)
		i+=1
		self.infoTable.setWidget(i,0,Label("Artist:") )
		self.infoTable.setWidget(i,1,self.artistLabel)
		i+=1
		self.infoTable.setWidget(i,0,Label("Track:") )
		self.infoTable.setWidget(i,1,self.trackLabel)
		i+=1
		self.infoTable.setWidget(i,0,Label("Album:") )
		self.infoTable.setWidget(i,1,self.albumLabel)
		
		self.statusPanel.add(self.infoTable)
		self.statusPanel.add(self.timeLabel)
		#make the time bar
		timebarWrapperPanel = SimplePanel()
		timebarWrapperPanel.setID("timebar_wrapper")
		#timebarWrapperPanel.setStyleName('timebar_wrapper')
		self.timebarPanel = SimplePanel()
		self.timebarPanel.setID("timebar")
		#self.timebarPanel.setStyleName('timebar')
		timebarWrapperPanel.add(self.timebarPanel)
		self.statusPanel.add(timebarWrapperPanel)
		#make some shit for buttons
		self.buttonHPanel = HorizontalPanel()
		self.skipButton = Button("Skip", self.clicked_skip )
		self.buttonHPanel.add(self.skipButton)
		loveButton = Button("Love", self.clicked_love )
		self.buttonHPanel.add(loveButton)
		pauseButton = Button("Pause", self.clicked_pause )
		self.buttonHPanel.add(pauseButton)
		banButton = Button("Ban", self.clicked_ban )
		self.buttonHPanel.add(banButton)

		#control the volume
		self.volumePanel = HorizontalPanel()
		self.volumeLabel = Label("Volume:")
		self.volumePanel.add(self.volumeLabel)
		volupButton = Button("+", self.clicked_volume_up, 5)
		self.volumePanel.add(volupButton)
		voldownButton = Button("-", self.clicked_volume_down, 5)
		self.volumePanel.add(voldownButton)
		
		#make buttons and shit to create a new station
		self.setStationHPanel = HorizontalPanel()
		self.setStationTypeListBox = ListBox()
		self.setStationTypeListBox.setVisibleItemCount(0)

		self.setStationTypeListBox.addItem("Similar Artists", "artist/%s/similarartists")
		self.setStationTypeListBox.addItem("Top Fans", "artist/%s/fans")
		self.setStationTypeListBox.addItem("Library", "user/%s/library")
		self.setStationTypeListBox.addItem("Mix", "user/%s/mix")
		self.setStationTypeListBox.addItem("Recommended", "user/%s/recommended")
		self.setStationTypeListBox.addItem("Neighbours", "user/%s/neighbours")
		self.setStationTypeListBox.addItem("Global Tag", "globaltags/%s")

		self.setStationHPanel.add(self.setStationTypeListBox)
		self.setStationTextBox = TextBox()
		self.setStationTextBox.setVisibleLength(10)
		self.setStationTextBox.setMaxLength(50)
		self.setStationHPanel.add(self.setStationTextBox)
		self.setStationButton = Button("Play", self.clicked_set_station)
		self.setStationHPanel.add(self.setStationButton)

		#make an error place to display data
		self.infoHTML = HTML()
		RootPanel().add(self.statusPanel)
		RootPanel().add(self.buttonHPanel)
		RootPanel().add(self.volumePanel)
		RootPanel().add(self.setStationHPanel)
		RootPanel().add(self.infoHTML)
		
	def run(self):
		self.get_track_info()

	def get_track_info(self):
		HTTPRequest().asyncGet("/track_info", TrackInfoHandler(self))
		Timer(5000,self.get_track_info)

	def clicked_skip(self):
		self.skipButton.setEnabled(False)
		HTTPRequest().asyncGet("/skip",ButtonInfoHandler(self,self.skipButton) )

	def clicked_volume_down(self):
		HTTPRequest().asyncGet("/volume/down",NullInfoHandler(self) )

	def clicked_volume_up(self):
		HTTPRequest().asyncGet("/volume/up",NullInfoHandler(self) )

	def clicked_love(self):
		HTTPRequest().asyncGet("/love",NullInfoHandler(self) )

	def clicked_ban(self):
		result = Window.confirm("Really ban this song?")
		if result:
			HTTPRequest().asyncGet("/ban",NullInfoHandler(self) )

	def clicked_pause(self):
		HTTPRequest().asyncGet("/pause",NullInfoHandler(self) )

	def clicked_set_station(self):
		type = self.setStationTypeListBox.getSelectedValues()[0]
		text = self.setStationTextBox.getText().strip()
		if len(text) > 0 :
			#clear the text
			self.setStationTextBox.setText("")
			station = type % text
			HTTPRequest().asyncGet("/station/%s" % station,NullInfoHandler(self) )

	def set_error(self, content):
		self.infoHTML.setHTML("<pre>%s</pre>" % content)
		
	def onTimeout(self,text):
		self.infoHTML.setHTML("timeout: "+text)
		
	def onError(self, text, code):
		self.infoHTML.setHTML(text + "<br />" + str(code))
		
	def process_track_info(self,text):
		#explode the text at ::
		#%a::%t::%l::%d::%R::%s::%v::%r
		data = text.split("::")
		artist = data[0]
		track = data[1]
		album = data[2]
		duration = data[3]
		played = int(duration)-int(data[4])
		percent = int( played/int(duration)*100 )
		self.artistLabel.setText( artist )
		self.trackLabel.setText( track )
		self.albumLabel.setText( album )
		#format time
		t = "%s : %d	%d" % (duration,played,percent)
		self.timeLabel.setText(data[7])
		#update the timebarwidth
		self.timebarPanel.setWidth("%d%" % (percent) )
		#set the station
		self.stationLabel.setText(data[5])
		#display the volume
		self.volumeLabel.setText("Volume: "+data[6])
		Window.setTitle(self.title+": "+artist+" - "+track)