예제 #1
0
def event_trade(_msg):
    global Trades
    _doc = document['trade']
    _dict = _msg['data']
    _id = "trade_{}_{}".format(_msg['_account_'], _dict['OrderRef'])
    _str = str(datetime.datetime.now(
    ))[11:19] + " [ {} ] {} {} {} 成交手数:{} 成交价:{}".format(
        _msg['_account_'], _dict['InstrumentID'],
        DirectionDict.get(_dict['Direction'], "未知方向"),
        OffsetFlagDict.get(_dict['OffsetFlag'], "未知开平"), _dict['Volume'],
        '%.2f' % float(_dict['Price']))
    _content = html.LABEL(_str)
    _content.style = DirectionStyle.get(_dict['Direction'], {})
    some = html.DIV(_content, id=_id)
    some.style = {"text-align": "left"}
    if Trades and Trades[0].id == _id:
        Trades = [some] + Trades[1:count]
    else:
        Trades = [some] + Trades[:count]
    _doc.clear()
    for one in Trades:
        _doc <= one
예제 #2
0
def event_account(_msg):
    global Accounts
    global AccDict
    _doc = document['account']
    _dict = _msg['data']
    _id = "account_{}".format(_msg['_account_'])
    Accounts.add(_id)
    _str = ''
    _str += width_label("帐号", 30)
    _str += width_label(_msg['_account_'], 80)
    _str += width_label("持仓盈亏", 50)
    _str += width_label('%.2f' % float(_dict['PositionProfit']), 80)
    _str += width_label("可用", 30)
    _str += width_label('%.2f' % float(_dict['Available']), 80)
    _str += width_label("净值", 30)
    _str += width_label('%.2f' % float(_dict['Balance']), 80)
    _content = html.LABEL(_str)
    some = html.DIV(_content, id=_id)
    some.style = {"text-align": "left"}
    AccDict[_id] = some
    _doc.clear()
    for one in Accounts:
        _doc <= AccDict[one]
예제 #3
0
def event_order(_msg):
    global Orders
    _doc = document['order']
    _dict = _msg['data']
    _id = "order_{}_{}".format(_msg['_account_'], _dict['OrderRef'])
    _str = str(datetime.datetime.now(
    ))[11:19] + " [ {} ] {} 报{}价:{} {} 手数:{} {}".format(
        _msg['_account_'], _dict['InstrumentID'],
        DirectionDict.get(_dict['Direction'],
                          "未知方向"), '%.2f' % float(_dict['LimitPrice']),
        OffsetFlagDict.get(_dict['CombOffsetFlag'], "未知开平"),
        _dict['VolumeTotalOriginal'], _dict['StatusMsg'])
    _content = html.LABEL(_str)
    _content.style = DirectionStyle.get(_dict['Direction'], {})
    some = html.DIV(_content, id=_id)
    some.style = {"text-align": "left"}
    if Orders and Orders[0].id == _id:
        Orders = [some] + Orders[1:count]
    else:
        Orders = [some] + Orders[:count]
    _doc.clear()
    for one in Orders:
        _doc <= one
예제 #4
0
    [1, '妙蛙種子', '1115', '草、毒'],
    [2, '妙蛙草', '1699', '草、毒'],
    [3, '妙蛙花', '2720', '草、毒'],
    [4, '小火龍', '980', '火'],
]
for line in lines:
    table <= html.TR(
        html.TD(line[0]) + html.TD(line[1]) + html.TD(line[2]) + html.TD(line[3]))
container <= table

# 寶貝圖鑑輸入表
container <= html.DIV(html.H2('寶貝圖鑑輸入表'),
                      Class="w3-container w3-blue  w3-margin-top")
form = html.FORM(Class="w3-container w3-border")
form <= html.DIV(
    html.LABEL('中文名') +
    html.INPUT(type="text", name="firstname", value="", Class="w3-input"))
form <= html.DIV(
    html.LABEL('最大CP') +
    html.INPUT(type="number", name="最大CP", value="", Class="w3-input"))
label3 = html.LABEL('屬性')
input3 = html.SELECT(Class="w3-select")
for option in ['...', '草、毒', '火', '水']:
    input3 <= html.OPTION(option)
form <= html.DIV(label3 + input3)
form <= html.P(html.BUTTON("上傳", Class="w3-button w3-red"))
container <= form


# 畫布 Html Canvas
container <= html.DIV(html.H2('Html Canvas'),
예제 #5
0
	def __init__(self, document, canv):
		'''Store the main window, create the Board and Deck models;
		create all the buttons and labels to allow the user to manipulate the game.
		'''

		self._doc = document
		self._canv = canv	# fabric Canvas object

		self._canv.on("mouse:up", self.onCardClick)

		self.loadCardMoveSound()
		self.loadCardInPlaceSound()
		self.loadEndOfRoundSound()
		self.loadFanfareSound()
		self._playSounds = True

		self._board = Board()
		self._deck = Deck()
		self._deck.addAllCards()
		self._copyOfDeck = self._deck.makeCopy()

		# We'll fill this in when we remove the aces from the board.
		self._removedAces = []

		# keeps track of cards that can be moved: each item is a tuple:
		# (card, row, col)
		self._moveableCards = []

		# A mapping from card object to CardImg object.  We do it this way
		# so that the card object (in the model) remains agnostic of the view
		# being used on it.
		self._card2ImgDict = {}

		self._score = 0
		# a list of templates of high scores we can update when high scores
		# change, so the screen changes immediately
		self._score_val = []
		self._storage = local_storage.storage
		self.loadSettingsFromStorage()

		# count of cards correctly placed, per round. 1st round is in
		# index 0, and initialized to 0 cards placed.
		self._cardsPlacedPerRound = [0]

		self._roundNum = 1

		# 2 rows of info about the game.
		self._game_info_elem = html.DIV(Class="game-info")
		self._doc <= self._game_info_elem
		self._game_info2_elem = html.DIV(Class="game-info")
		self._doc <= self._game_info2_elem

		self._next_round_btn = html.BUTTON(
			"Next Round", Class="button", disabled=True)
		self._next_round_btn.bind('click', self.nextRound)
		self._game_info_elem <= self._next_round_btn

		self._round_info_elem = \
			html.SPAN("Round: {roundNum}",
					  Class="info-text", id="round_num")
		self._game_info_elem <= self._round_info_elem
		self._round_num_val = template.Template(self._round_info_elem)
		self.updateRoundNum()

		self._cardsInPlace = self._board.countCardsInPlace()
		self._cards_in_place_elem = html.SPAN(
			"Cards in place: {cardsInPlace}", Class="info-text")
		self._game_info_elem <= self._cards_in_place_elem
		self._cardsInPlace_val = template.Template(self._cards_in_place_elem)
		self.updateCardsInPlace()

		self._score_info_elem = html.SPAN(
			"Score: {score}", Class="info-text")
		self._game_info_elem <= self._score_info_elem
		self._scoreInfo_val = template.Template(self._score_info_elem)

		self._pts_per_card_info_elem = html.SPAN(
			"Pts per card: {ptsPerCard}", Class="info-text")
		self._game_info_elem <= self._pts_per_card_info_elem
		self._ptsPerCardInfo_val = template.Template(
			self._pts_per_card_info_elem)
		self.updateScore()

		self._new_game_btn = html.BUTTON(
			"New Game", Class="button", disabled=True)
		self._new_game_btn.bind('click', self.newGameClickHandler)
		self._game_info_elem <= self._new_game_btn

		self._repeat_game_btn = html.BUTTON(
			"Repeat Game", Class="button")
		self._repeat_game_btn.bind('click', self.repeatGameClickHandler)
		self._game_info_elem <= self._repeat_game_btn

		self._messageDiv = self.createMessageDiv()

		switch_button = html.BUTTON ('Switch Deck', Class = 'button')
		switch_button.bind ('click', switch_card_sources)
		self._game_info_elem <= switch_button

		self._status_elem = html.SPAN("{status}")
		self._game_info2_elem <= self._status_elem
		self._status_val = template.Template(self._status_elem)
		self.setStatus("Cards placed this round: 0")

		self._playSoundsSpan = html.SPAN()
		self._game_info2_elem <= self._playSoundsSpan
		self._playSoundsLabel = html.LABEL("Play sounds: ")
		self._playSoundsSpan <= self._playSoundsLabel
		self._playSoundsCheckBox = html.INPUT(
			type="checkbox", checked=self._playSounds)
		self._playSoundsCheckBox.bind('click', self.togglePlaySounds)
		self._playSoundsSpan <= self._playSoundsCheckBox

		# A mapping from Card object to CardImg object.  This is needed so
		# that we map a card in the board layout to the CardImg, which should
		# then be placed at a certain location.  (We don't keep a reference to
		# the CardImg in Card because it just shouldn't know how it is displayed.)
		cards = self._deck.getCards()
		for card in cards:
			cardimg = CardImg(card, self._canv)
			self._card2ImgDict[id(card)] = cardimg

		self._boardGui = BoardGui(self._board, self._canv, self._card2ImgDict)

		self.loadHighScores()

		self.initNewGame()
예제 #6
0
def width_label(c, width):
    if type(c) == type(.1):
        c = '%.2f' % c
    s = html.LABEL(c)
    s.style = {"display": "inline-block", "width": "%dpx" % width}
    return s
def show_contact(evt):
    """
  Show the contact form
  """
    if len(document['contact_container'].text) > 0:
        document['contact_container'].html = ""
        return

    form = html.FORM(id="contact_form", method='post', action='/contact_form')

    div = html.DIV()
    div <= html.BR() + html.BR()

    label = html.LABEL()
    span = html.SPAN()
    span.text = "Name (required): "
    widget = html.INPUT(id="name",
                        placeholder="Name",
                        type="text",
                        tabindex="1",
                        required=True,
                        autofocus=True)
    label <= span + html.BR() + widget
    div <= label
    form <= div

    div = html.DIV()
    label = html.LABEL()
    span = html.SPAN()
    span.text = "Email (required): "
    widget = html.INPUT(id="email",
                        placeholder="Email address",
                        type="email",
                        tabindex="2",
                        size="30",
                        required=True)
    label <= span + html.BR() + widget
    div <= label
    form <= div

    div = html.DIV()
    label = html.LABEL()
    span = html.SPAN()
    span.text = "Other (if you type anything in this box your message will be trashed): "
    widget = html.INPUT(id="other",
                        placeholder="Don't do it.",
                        type="text",
                        tabindex="3",
                        required=True)
    label <= span + html.BR() + widget
    div <= label
    form <= div

    div = html.DIV()
    label = html.LABEL()
    span = html.SPAN()
    span.text = "Are you a human? If so, how many legs does a dog have? "
    widget = html.INPUT(id="magic",
                        placeholder="How many?",
                        type="text",
                        tabindex="4",
                        size="9",
                        required=True)
    label <= span + html.BR() + widget
    div <= label
    form <= div

    div = html.DIV()
    label = html.LABEL()
    span = html.SPAN()
    span.text = "Message: "
    widget = html.TEXTAREA(id="message",
                           placeholder="Type your message",
                           tabindex="5",
                           cols="60",
                           required=True)
    label <= span + html.BR() + widget
    div <= label
    form <= div

    div = html.DIV()
    button = html.BUTTON(type="button", id="contact_submit")
    button.text = "Submit Message"
    div <= button
    form <= div

    document['contact_container'] <= form
    document['contact_submit'].bind('click', submit_contact)
    window.scrollBy(0, 50)
예제 #8
0
def draw_home1():
    panel = document["main_panel"]
    table0 = html.TABLE()
    tableBody0 = html.TBODY()
    row0 = html.TR()

    b21 = html.P(id="status_indicator")

    #b21.text = "READY"
    #b21.style.verticalAlign = "bottom"
    #b21.style.marginRight = "40px"
    #g21.style.background = "#3366FF"
    #g21.style.color = "#FFEE00"
    #b21.style.background = "#55FF55"
    #b21.style.width = "120px"
    #b21.style.textAlign = "center"
    #b21.style.padding = "10px 0px 10px 0px"
    #b21.style.font = "16px verdana"
    #b21.style.border = "thin solid green"

    td01 = html.TD()
    td01 <= b21
    row0 <= td01

    head = html.LABEL("GeneXpresso - analyze DNA microarray datasets")
    head.style.font = "30px verdana"
    head.style.textAlign = "center"
    td02 = html.TD()
    td02 <= head
    row0 <= td02

    tableBody0 <= row0
    table0 <= tableBody0
    panel <= table0

    panel <= html.BR()

    status_indicator_ready(0)

    table1 = html.TABLE()
    table1.style.border = "none"
    table1.style.fontSize = "large"
    table1.style.background = "#F7F7F7"
    #table1.style.marginLeft = "50px"
    #b.style.marginTop = "30px"
    #
    table1.style.padding = "10px 20px 10px 10px"
    table1.style.font = "16px verdana"

    tableBody1 = html.TBODY()

    g1 = html.TR()

    g11 = html.LABEL("Search datasets by keyword:")
    g11.style.verticalAlign = "bottom"
    g11.style.marginRight = "10px"

    td_1 = html.TD()
    td_1 <= g11
    g1 <= td_1

    g12 = html.INPUT(id="g12")
    g12.style.verticalAlign = "bottom"
    g12.style.marginRight = "20px"

    td_2 = html.TD()
    td_2 <= g12
    g1 <= td_2

    g13 = html.LABEL("Search in:")
    g13.style.verticalAlign = "bottom"
    g13.style.marginRight = "10px"

    td_3 = html.TD()
    td_3 <= g13
    g1 <= td_3

    op1 = html.OPTION("title")
    op2 = html.OPTION("description")
    op3 = html.OPTION("dataset ID")
    op4 = html.OPTION("pubmed ID")
    op5 = html.OPTION("gene")
    op6 = html.OPTION("probe")
    sel1 = html.SELECT([op1, op2, op3, op4, op5, op6],
                       id="selector1",
                       font_size=12)
    sel1.style.fontSize = "large"
    sel1.style.verticalAlign = "bottom"

    td_4 = html.TD()
    td_4 <= sel1
    g1 <= td_4

    global bSearch1
    bSearch1 = html.BUTTON('Search')
    button_style_default(bSearch1)
    #bSearch1.bind('click', click_search1)
    bSearch1.bind('mouseout', mouse_out_search1)
    bSearch1.bind('mouseover', mouse_over_search1)
    bSearch1.style.verticalAlign = "top"
    bSearch1.bind('click', datasets_by_keyword_search)

    td_5 = html.TD()
    td_5 <= bSearch1
    g1 <= td_5

    tableBody1 <= g1
    table1 <= tableBody1
    panel <= table1
    panel <= html.BR()
예제 #9
0
def draw_home2():
    panel = document["main_panel"]

    table21 = html.TABLE()
    table21.style.fontSize = "large"
    table21.style.font = "16px verdana"

    tableBody21 = html.TBODY()

    #table22 = html.TABLE()
    #tableBody22 = html.TBODY()

    row21_1 = html.TR()
    #row21_2 = html.TR()

    table21.style.background = "#F7F7F7"
    table21.style.padding = "10px 25px 10px 10px"

    #table22.style.background = "#F7F7F7"
    #table22.style.padding = "10px 15px 10px 10px"

    label21 = html.LABEL("Search gene expressions by:")
    label21.style.verticalAlign = "center"
    label21.style.marginRight = "10px"

    td_1 = html.TD()
    td_1 <= label21
    row21_1 <= td_1

    op1 = html.OPTION("probe name")
    op2 = html.OPTION("gene name")
    sel2 = html.SELECT([op2, op1], id="select_probe_or_gene", font_size=16)
    sel2.style.fontSize = "large"
    sel2.style.verticalAlign = "center"
    sel2.style.marginRight = "20px"

    td_2 = html.TD()
    td_2 <= sel2
    row21_1 <= td_2

    inp21 = html.INPUT(id="input_probe_or_gene")
    inp21.style.verticalAlign = "center"
    inp21.style.marginRight = "0px"

    td_3 = html.TD()
    td_3 <= inp21
    row21_1 <= td_3

    global bSearch2
    bSearch2 = html.BUTTON('Search')
    button_style_default(bSearch2)
    bSearch2.bind('click', click_search2)
    bSearch2.bind('mouseout', mouse_out_search2)
    bSearch2.bind('mouseover', mouse_over_search2)
    bSearch2.style.verticalAlign = "center"

    td_4 = html.TD()
    td_4 <= bSearch2
    row21_1 <= td_4

    #label22 = html.LABEL("Search gene expressions by gene name:")
    #label22.style.verticalAlign = "bottom"
    #label22.style.marginRight = "10px"
    #row21_2 <= label22
    #inp22 = html.INPUT()
    #inp22.style.verticalAlign = "bottom"
    #inp22.style.marginRight = "0px"
    #row21_2 <= inp22
    #global bSearch3
    #bSearch3 = html.BUTTON('Search')
    #button_style_default(bSearch3)
    #bSearch3.bind('click', click_search3)
    #bSearch3.bind('mouseout', mouse_out_search3)
    #bSearch3.bind('mouseover', mouse_over_search3)
    #bSearch3.style.verticalAlign = "top"
    #row21_2 <= bSearch3

    tableBody21 <= row21_1
    #tableBody22 <= row21_2
    table21 <= tableBody21
    #table22 <= tableBody22

    panel <= table21
    panel <= html.BR()
    #panel <= table22

    #############################################

    table23 = html.TABLE()
    table23.style.font = "16px verdana"
    table23.style.background = "#F7F7F7"
    table23.style.padding = "20px 25px 20px 10px"

    tableBody23 = html.TBODY()

    row23_1 = html.TR()
    row23_2 = html.TR()
    row23_3 = html.TR()

    label23_1 = html.LABEL("Min sample size:")
    #label23_1.style.verticalAlign = "bottom"
    label23_1.style.marginRight = "10px"
    row23_1 <= label23_1

    op21 = html.OPTION("5")
    op22 = html.OPTION("10")
    op23 = html.OPTION("15")
    op24 = html.OPTION("20")
    op25 = html.OPTION("25")
    sel23_1 = html.SELECT([op21, op22, op23, op24, op25],
                          id="selector_min_sample_size",
                          font_size=16)
    sel23_1.style.fontSize = "large"
    #sel23_1.style.verticalAlign = "bottom"
    sel23_1.style.marginRight = "50px"
    row23_1 <= sel23_1

    #inp23_1 = html.INPUT()
    #inp23_1.style.verticalAlign = "bottom"
    #inp23_1.style.marginRight = "0px"
    #row23_1 <= inp23_1

    label23_2 = html.LABEL("Max p-value:")
    label23_2.style.verticalAlign = "bottom"
    label23_2.style.marginRight = "10px"
    row23_1 <= label23_2

    op31 = html.OPTION("1E-6")
    op32 = html.OPTION("1E-5")
    op33 = html.OPTION("1E-4")
    op34 = html.OPTION("1E-3")
    op35 = html.OPTION("0.005")
    op36 = html.OPTION("0.01")
    op37 = html.OPTION("0.02")
    op38 = html.OPTION("0.05")
    sel23_2 = html.SELECT([op38, op37, op36, op35, op34, op33, op32, op31],
                          id="selector_max_pvalue",
                          font_size=16)
    sel23_2.style.fontSize = "large"
    #sel23_1.style.verticalAlign = "bottom"
    sel23_2.style.marginRight = "50px"
    row23_1 <= sel23_2

    #inp23_2 = html.INPUT()
    #inp23_2.style.verticalAlign = "bottom"
    #inp23_2.style.marginRight = "0px"
    #row23_1 <= inp23_2

    label23_3 = html.LABEL("Max # results:")
    label23_3.style.verticalAlign = "bottom"
    label23_3.style.marginRight = "10px"
    row23_1 <= label23_3

    op44 = html.OPTION("1000")
    op45 = html.OPTION("500")
    op46 = html.OPTION("300")
    op47 = html.OPTION("200")
    op48 = html.OPTION("100")
    sel23_3 = html.SELECT([op48, op47, op46, op45, op44],
                          id="selector_max_num_results",
                          font_size=16)
    sel23_3.style.fontSize = "large"
    #sel23_3.style.verticalAlign = "bottom"
    sel23_3.style.marginRight = "0px"
    row23_1 <= sel23_3

    #inp23_3 = html.INPUT()
    #inp23_3.style.verticalAlign = "bottom"
    #inp23_3.style.marginRight = "0px"
    #row23_1 <= inp23_3

    tableBody23 <= row23_1
    #tableBody23 <= row23_2
    #tableBody23 <= row23_3

    table23 <= tableBody23
    panel <= table23

    panel <= html.BR()
예제 #10
0
def draw_home_title_description():
    panel = document["main_panel"]

    table = html.TABLE()
    table.style.fontSize = "large"
    table.style.font = "16px verdana"

    tableBody = html.TBODY()
    row = html.TR()

    tableBody.style.verticalAlign = "center"
    row.style.verticalAlign = "center"

    table.style.background = "#F7F7F7"
    table.style.padding = "10px 10px 10px 10px"

    label = html.LABEL("Details for dataset:", id="label_details_for_dataset")
    label.style.verticalAlign = "center"
    label.style.marginRight = "10px"

    td1 = html.TD()
    td1 <= label
    td1.style.width = "200px"
    row <= td1

    div2 = html.DIV()
    div2.style.overflow = "scroll"
    div2.height = 100
    div2.width = 250

    title_text_area = html.TEXTAREA("Title:", id="dataset_title")
    title_text_area.readOnly = True
    #title_text_area.disabled = True
    title_text_area.style.font = "14px verdana"
    title_text_area.rows = 10
    title_text_area.cols = 26
    div2 <= title_text_area

    td2 = html.TD()
    td2 <= div2
    row <= td2

    div3 = html.DIV()
    div3.style.overflow = "scroll"
    div3.height = 100
    div3.width = 450

    description_text_area = html.TEXTAREA("Description:",
                                          id="dataset_description")
    description_text_area.readOnly = True
    #description_text_area.disabled = True
    description_text_area.style.font = "14px verdana"
    description_text_area.rows = 10
    description_text_area.cols = 51
    div3 <= description_text_area

    td3 = html.TD()
    td3 <= div3
    row <= td3

    tableBody <= row
    table <= tableBody
    panel <= table
    panel <= html.BR()
예제 #11
0
def draw_home_samples(sample1, sample2):
    panel = document["main_panel"]

    table = html.TABLE()
    table.style.fontSize = "large"
    table.style.font = "16px verdana"

    tableBody = html.TBODY()
    row = html.TR()

    tableBody.style.verticalAlign = "center"
    row.style.verticalAlign = "center"

    table.style.background = "#F7F7F7"
    table.style.padding = "10px 25px 10px 10px"

    label = html.LABEL("Select samples to search:")
    label.style.verticalAlign = "center"
    label.style.marginRight = "10px"

    td1 = html.TD()
    td1 <= label
    row <= td1

    #op11 = html.OPTION(sample1)
    #op12 = html.OPTION(sample2)

    #op21 = html.OPTION(sample1)
    #op22 = html.OPTION(sample2)

    sel1 = html.SELECT([], id="selector_samples_1", font_size=16)
    sel1.style.fontSize = "large"
    sel1.style.verticalAlign = "center"
    sel1.style.marginRight = "20px"
    sel1.style.width = "300px"

    td2 = html.TD()
    td2 <= sel1
    row <= td2

    sel2 = html.SELECT([], id="selector_samples_2", font_size=16)
    sel2.style.fontSize = "large"
    sel2.style.verticalAlign = "center"
    sel2.style.marginRight = "0px"
    sel2.style.width = "300px"

    td3 = html.TD()
    td3 <= sel2
    row <= td3

    b = html.BUTTON('Search', id="search_subsets")
    button_style_default(b)
    b.bind('click', click_search_subsets)
    b.bind('mouseout', mouse_out_search_subsets)
    b.bind('mouseover', mouse_over_search_subsets)
    b.style.verticalAlign = "center"
    b.style.marginTop = "0px"
    b.style.marginBottom = "0px"

    td4 = html.TD()
    td4.style.verticalAlign = "center"
    td4 <= b
    row <= td4

    tableBody <= row
    table <= tableBody

    panel <= table
    panel <= html.BR()
예제 #12
0
def spellEdit(spell : str) -> dialog.Dialog:
	def toggleDamage(event):
		for i in d.select(".damage"):
			if event.target.checked:
				del i.attrs["readonly"]
			else:
				i.attrs["readonly"] = ''

	d = dialog.Dialog(spell, ok_cancel = True, default_css = False)

	d.panel <= html.LABEL("Spell Name:", For = "name")
	d.panel <= html.INPUT(id = "name", Class = "dialogName")
	d.panel <= html.BR()
	d.panel <= html.LABEL("Spell Description:", For = "description")
	d.panel <= html.INPUT(id = "description")
	d.panel <= html.BR()

	d.panel <= html.LABEL("Spell Level:", For = "level")
	d.panel <= html.INPUT(id = "level", type = "number", min = 0, max = 9, value = 0)
	d.panel <= html.LABEL("Spell School:", For = "school")
	spellSchool = html.SELECT(id = "school", name = "school")
	for school in (
		"abjuration", "conjuration", "divination", "enchantment",
		"evocation", "illusion", "necromancy", "transmutation"
	):
		spellSchool <= html.OPTION(school.capitalize(), value = school)
	d.panel <= spellSchool
	d.panel <= html.BR()

	d.panel <= html.LABEL("Spell Range (Measure, Unit):", For = "rangeMeasure")
	d.panel <= html.INPUT(id = "rangeMeasure", type = "number", min = 0, value = 0)
	rangeUnit = html.SELECT(id = "rangeUnit", name = "rangeUnit")
	for unit in ("feet", "touch", "self"):
		rangeUnit <= html.OPTION(unit.capitalize(), value = unit)
	d.panel <= rangeUnit
	d.panel <= html.BR()
	d.panel <= html.P(
		"For touch and non-AoE self ranges, leave the Measure field at 0."
	)
	d.panel <= html.BR()

	d.panel <= html.LABEL("Spell Casting Time (Measure, Unit):", For = "castingMeasure")
	d.panel <= html.INPUT(id = "castingMeasure", type = "number", min = 1, value = 1)
	castingUnit = html.SELECT(id = "castingUnit", name = "castingUnit")
	for unit in ("bonus Action", "action", "minutes", "hours"):
		castingUnit <= html.OPTION(unit.capitalize(), value = unit)
	d.panel <= castingUnit
	d.panel <= html.BR()

	d.panel <= html.LABEL("Spell Duration (Measure, Unit):", For = "durationMeasure")
	d.panel <= html.INPUT(id = "durationMeasure", type = "number", min = 0, value = 0)
	durationUnit = html.SELECT(id = "durationUnit", name = "durationUnit")
	for unit in (
		"days", "hours", "minutes", "rounds",
		"days, Concentration", "hours, Concentration",
		"minutes, Concentration", "rounds, Concentration",
		"instantaneous", "until Dispelled", "special"
	):
		durationUnit <= html.OPTION(unit.capitalize(), value = unit)
	d.panel <= durationUnit
	d.panel <= html.BR()
	d.panel <= html.P(
		"For instantaneous, until dispelled, or special durations, leave the Measure field at 0."
	)
	d.panel <= html.BR()

	d.panel <= html.LABEL("Does Damage?", For = "damageCheckbox")
	damageCheckbox = html.INPUT(id = "damageCheckbox", type = "checkbox")
	damageCheckbox.bind("change", toggleDamage)
	d.panel <= damageCheckbox
	d.panel <= html.BR()

	d.panel <= html.LABEL("Damage Dice Count:", For = "damageCount")
	d.panel <= html.INPUT(
		id = "damageCount", Class = "damage",
		type = "number", min = 1, value = 1, readonly = ''
	)
	d.panel <= html.LABEL("Damage Dice Value:", For = "damageDie")
	d.panel <= html.INPUT(
		id = "damageDie", Class = "damage",
		type = "number", min = 4, value = 4, readonly = ''
	)
	d.panel <= html.BR()
	d.panel <= html.LABEL("Damage Type:", For = "damageType")
	d.panel <= html.INPUT(id = "damageType", Class = "damage", readonly = '')

	return d
예제 #13
0
def itemEdit(item : str) -> dialog.Dialog:
	d = dialog.Dialog(item, ok_cancel = True, default_css = False)
	def toggleWeapon(event):
		for i in d.select(".weapon"):
			if i.type == "radio" or i.type == "checkbox":
				if event.target.checked:
					del i.attrs["disabled"]
				else:
					i.attrs["disabled"] = ''
			elif i.type == "number":
				if event.target.checked:
					del i.attrs["readonly"]
				else:
					i.attrs["readonly"] = ''

	d.panel <= html.LABEL("Item Name:", For = "name")
	d.panel <= html.INPUT(id = "name", Class = "dialogName")
	d.panel <= html.BR()
	d.panel <= html.LABEL("Item Description:", For = "desc")
	d.panel <= html.INPUT(id = "description")
	d.panel <= html.BR()
	d.panel <= html.LABEL("Item Count:", For = "count")
	d.panel <= html.INPUT(id = "count", type = "number", min = 0)
	d.panel <= html.LABEL("Item Weight:", For = "weight")
	d.panel <= html.INPUT(id = "weight", type = "number", min = 0, step = 0.01)
	d.panel <= html.BR()

	d.panel <= html.P("Value")
	d.panel <= html.LABEL("Gold:", For = "gold")
	d.panel <= html.INPUT(id = "gold", type = "number", min = 0)
	d.panel <= html.LABEL("Silver:", For = "silver")
	d.panel <= html.INPUT(id = "silver", type = "number", min = 0, max = 10)
	d.panel <= html.LABEL("Copper:", For = "copper")
	d.panel <= html.INPUT(id = "copper", type = "number", min = 0, max = 10)
	d.panel <= html.BR()

	weaponTitleTag = html.P("Weapon")
	weaponCheck = html.INPUT(id = "weaponCheck", type = "checkbox")
	weaponCheck.bind("change", toggleWeapon)
	weaponTitleTag <= weaponCheck
	weaponTitleTag <= html.LABEL("Is Weapon?", For = "weaponCheck")
	d.panel <= weaponTitleTag

	d.panel <= html.P("Kind")
	d.panel <= html.INPUT(
		id = "weaponTypeSM", Class = "weapon", type = "radio",
		name = "kind", value = "simpleMelee", disabled = ''
	)
	d.panel <= html.LABEL("Simple Melee", For = "weaponTypeSM")
	d.panel <= html.INPUT(
		id = "weaponTypeSR", Class = "weapon", type = "radio",
		name = "kind", value = "simpleRanged", disabled = ''
	)
	d.panel <= html.LABEL("Simple Ranged", For = "weaponTypeSR")
	d.panel <= html.INPUT(
		id = "weaponTypeMM", Class = "weapon", type = "radio",
		name = "kind", value = "martialMelee", disabled = ''
	)
	d.panel <= html.LABEL("Martial Melee", For = "weaponTypeMM")
	d.panel <= html.INPUT(
		id = "weaponTypeMR", Class = "weapon", type = "radio",
		name = "kind", value = "martialRanged", disabled = ''
	)
	d.panel <= html.LABEL("Martial Ranged", For = "weaponTypeMR")
	d.panel <= html.BR()

	d.panel <= html.P("Damage Type")
	d.panel <= html.INPUT(
		id = "damageTypeB", Class = "weapon", type = "radio",
		name = "type", value = "bludgeoning", disabled = ''
	)
	d.panel <= html.LABEL("Bludgeoning", For = "damageTypeB")
	d.panel <= html.INPUT(
		id = "damageTypeP", Class = "weapon", type = "radio",
		name = "type", value = "piercing", disabled = ''
	)
	d.panel <= html.LABEL("Piercing", For = "damageTypeP")
	d.panel <= html.INPUT(
		id = "damageTypeS", Class = "weapon", type = "radio",
		name = "type", value = "slashing", disabled = ''
	)
	d.panel <= html.LABEL("Slashing", For = "damageTypeS")
	d.panel <= html.BR()
	d.panel <= html.INPUT(
		id = "isProficient", Class = "weapon",
		type = "checkbox", disabled = ''
	)
	d.panel <= html.LABEL("Proficient?", For = "isProficient")
	d.panel <= html.INPUT(
		id = "bonusFromSTR", Class = "weapon", type = "radio",
		name = "ability", value = "str", disabled = ''
	)
	d.panel <= html.LABEL("Strength (Melee*)", For = "bonusFromSTR")
	d.panel <= html.INPUT(
		id = "bonusFromDEX", Class = "weapon", type = "radio",
		name = "ability", value = "dex", disabled = ''
	)
	d.panel <= html.LABEL("Dexterity (Ranged*)", For = "bonusFromDEX")
	d.panel <= html.BR()

	d.panel <= html.P("* Finesse weapons can derive from either ability per player choice")

	d.panel <= html.P("Damage Values")
	d.panel <= html.LABEL("Damage Dice Count:", For = "dmgCount")
	d.panel <= html.INPUT(
		id = "dmgCount", Class = "weapon",
		type = "number", min = 0, readonly = ''
	)
	d.panel <= html.LABEL("Damage Dice Value:", For = "dmgDie")
	d.panel <= html.INPUT(
		id = "dmgDie", Class = "weapon",
		type = "number", min = 0, readonly = ''
	)
	d.panel <= html.BR()
	d.panel <= html.LABEL("Damage Bonus:", For = "dmgBonus")
	d.panel <= html.INPUT(
		id = "dmgBonus", Class = "weapon",
		type = "number", min = 0, readonly = ''
	)

	return d
예제 #14
0
파일: monitor.py 프로젝트: keel1982/web_ctp
def width_label(c, width):
    s = html.LABEL(c)
    s.style = {"display": "inline-block", "width": "%dpx" % width}
    return s