我正在使用Django表单进行输入.但是,我想稍微定制一下.例如,以下Django代码将被翻译成:
#Django code
aerial_size_dist = forms.ChoiceField(initial='Very Fine to Fine')
#Translated HTML
<tr><th><label for="id_aerial_size_dist">Aerial size dist:</label></th><td><select name="aerial_size_dist" id="id_aerial_size_dist"></select></td></tr>
Run Code Online (Sandbox Code Playgroud)
我的问题是如何从Django端添加一个标签属性,如"style"?小部件可以更改Django表单标签属性吗?
<tr><th><label for="id_aerial_size_dist" style="display:none;">Aerial size dist:</label></th><td><select name="aerial_size_dist" id="id_aerial_size_dist"></select></td></tr>
Run Code Online (Sandbox Code Playgroud) 不确定我是否应该使用这个术语.基本上,我有一个反应功能,显示用户上传的CSV文件,我想使用一个action button来激活绘图生成过程.此时,该图总是在运行中生成.所以我想知道,在renderPlot函数中,如何action button覆盖reactive元素.谢谢!
library(shiny)
shinyUI(fluidPage(
titlePanel("Test"),
sidebarLayout(
sidebarPanel(
fileInput('file1', 'Choose CSV File',
accept=c('text/csv',
'text/comma-separated-values,text/plain',
'.csv')),
checkboxGroupInput('show_vars', 'Columns to show:',
choices=c("Col1"="Col1", "Col2"="Col2", "Col3"="Col3"),
c("Col1"="Col1", "Col2"="Col2", "Col3"="Col3")),
uiOutput("study"),
actionButton("go", "Draw the plot")
),
mainPanel(
dataTableOutput('contents'),
plotOutput("Plot", width = 800, height = 800)
)
)
))
Run Code Online (Sandbox Code Playgroud)
shinyServer(function(input, output) {
dataInput <- reactive({
inFile <- input$file1
if (is.null(inFile)) return(NULL)
data_load<-subset(read.csv(inFile$datapath, header=T, sep=",", quote='"', stringsAsFactors=FALSE), select=input$show_vars)
data_study<-unique(data_load$Col2)
return (list("data_load"=data_load, "data_study"=data_study))
})
study <- reactive({
all_citation<-dataInput()$data_load$Col2 …Run Code Online (Sandbox Code Playgroud) 我需要从这个站点抓取这些超链接背后的一些数据。但是,这些超链接是javascript function calls,稍后提交form使用post方法。经过一番搜索,selenium似乎是一个候选人。所以我的问题是,我应该如何正确设置输入标签的值并提交不提交按钮的表单。
from selenium import webdriver
url = "http://www.echemportal.org/echemportal/propertysearch/treeselect_input.action?queryID=PROQ3h3n"
driver = webdriver.Firefox()
driver.get(url)
treePath_tag = driver.find_element_by_name("treePath")
Run Code Online (Sandbox Code Playgroud)
在提交表单之前,我需要为 tag 赋值<input>。但是,我遇到了错误
消息:元素当前不可见,因此可能无法与之交互
treePath_tag.send_keys('/TR.SE00.00/QU.SE.DATA_ENV/QU.SE.ENV_ENVIRONMENT_DATA/QU.SE.EN_MONITORING')
Run Code Online (Sandbox Code Playgroud)
如果以上正确,我想以这种方式提交表格。这是正确的吗?
selenium.find_element_by_name("add_form").submit()
Run Code Online (Sandbox Code Playgroud)
以下是网页的来源。
<script type="text/javascript">
function AddBlock(path){
document.add_form.treePath.value=path;
document.add_form.submit();
}
</script>
Run Code Online (Sandbox Code Playgroud)
<form id="addblock_input" name="add_form" action="/echemportal/propertysearch/addblock_input.action" method="post" style="display:none;">
<table class="wwFormTable" style="display:none;"><tr style="display:none;">
<td colspan="2">
<input type="hidden" name="queryID" value="PROQ3h1w" id="addblock_input_queryID"/> </td>
</tr>
<tr style="display:none;">
<td colspan="2">
<input type="hidden" name="treePath" value="" id="addblock_input_treePath"/> </td>
</tr>
</table></form>
Run Code Online (Sandbox Code Playgroud)
我需要将dataframesR 中的一些大文件保存到硬盘上。由于每个文件的尺寸DF都很大(〜> 50K行和> 50列),并且我有超过200K,我想压缩保存它们以节省一些硬盘空间。
到目前为止,我尝试了几种类型,例如.CSV, rds( compress = "gzip") ,分别需要 ~60MB和20 MB。我想知道是否有一些替代方法可以更有效地压缩它们。
数据属性的东西对我来说是新手,只是意识到我需要逃避空格,逗号等。有人可以给我一些有关我的方法的建议吗?下面是我的代码:
#A list holds all the strings to be sent to data-attribute,
#the sequence and length of the list is dynamic, determined by the user
#(That's why I need to find a way to escape automatically.
Apt_p = []
Apt_p.append('Relative to planting')
Apt_p.append('Relative to harvest')
Apt_p_j=json.dumps(Apt_p) #convert everything into JSON for future usage
#I think below is the place to let escape happen.
html = """<td id="Apt_p_j" data-val=%s></td>""" %(Apt_p_j)
Run Code Online (Sandbox Code Playgroud) 我的案子有两个步骤:
1)用户将从下拉列表中选择建模阶段数.2)根据用户输入,我使用.appendTo方法动态创建HTML表.
除IE7外,chrome,firefox,IE9上的一切都很顺利.我的一些用户拥有IE7,不允许更新.所以我必须解决这个问题.真的很感激任何评论.
以下是Chrome和IE9中的外观示例
以下是我的代码:
HTML代码:
<div class="articles">
<table align="center">
<tr><th><label for="id_S">Number of modeled stages:</label></th><td><select name="S" id="id_S">
<option value="">Please choose</option>
<option value="2">2</option>
<option value="3">3</option>
<option value="4">4</option>
<option value="5">5</option>
<option value="6">6</option>
<option value="7">7</option>
</select></td></tr>
</table></div>
Run Code Online (Sandbox Code Playgroud)
JavaScript代码:
$(".articles").find('table').addClass('table');
$('#id_S').change(function() {
$('.leslie').remove();
$('.no').remove();
var total = $(this).val()
$('<table class="leslie" border="0" align="center"><tr><th width="5" colspan=' + total + '>Lesile Matrix:</th></tr>').appendTo('.table');
i = 0
while (i < total) {
$('<tr>').appendTo('.leslie')
var j = 0
while (j < total) {
$('<td><input …Run Code Online (Sandbox Code Playgroud) 我知道这是非常基本的.我想使用jQuery来更改由Django生成的下拉字段的标签.
这是HTML代码:
<div class="form-fields">
<table>
<tr><th><label for="id_Ap_m">Application method 1:</label></th><td><select name="Ap_m" id="id_Ap_m">
<option value="" selected="selected">Select an application method</option>
<option value="1">Aerial</option>
<option value="2">Ground Sprayer</option>
</select></td></tr>
</table>
</div>
Run Code Online (Sandbox Code Playgroud)
jQuery代码:
$(document).ready(function(){
$('#id_Ap_m').html('New application');
});
Run Code Online (Sandbox Code Playgroud)
我的目标是将"应用方法1"更改为"新应用程序".我的方法是根据其ID选择此标签,然后更改文本.但是,我的代码不起作用.这可能是因为标签和下拉列表都有相同的id(id_Ap_m),它是由Django生成的.
有什么建议?
我需要更新一些超过2GB文件的最后一行,这些文件由无法读取的文本行组成readlines().目前,它通过逐行循环工作正常.但是,我想知道是否有任何编译库可以更有效地实现这一点?谢谢!
myfile = open("large.XML")
for line in myfile:
do_something()
Run Code Online (Sandbox Code Playgroud) html ×3
javascript ×3
jquery ×3
python ×2
r ×2
appendto ×1
compression ×1
csv ×1
django ×1
django-forms ×1
forms ×1
gzip ×1
html5 ×1
io ×1
jqplot ×1
json ×1
selenium ×1
shiny ×1
shiny-server ×1