如何改进我的HTML代码并在Php中单击按钮触发python 文件排列门户 /*.第2分部{ 宽度:400px; 背景色:黑色; 高度:100px; 填充:250px; 边框:1px纯灰; 位置:绝对位置; 左:50%; 最高:60%; 转换:转换(-50%,-50%) } p2{ 背景颜色:灰色; 左:100px; 顶部:100px: } */ .按钮1{ 背景色:#4CAF50;/*绿色*/ 位置:绝对位置; 边界:无; 颜色:白色; 填充:10px 22px; 文本对齐:居中; 文字装饰:无; 显示:内联块; 字体大小:14px; 最高:195%; 左:30% } .按钮2{ 背景色:#4CAF50;/*绿色*/ 位置:绝对位置; 边界:无; 颜色:白色; 填充:10px 22px; 文本对齐:居中; 文字装饰:无; 显示:内联块; 字体大小:14px; 最高:210%; 左:33% } .按钮3{ 背景色:#4CAF50;/*绿色*/ 位置:绝对位置; 边界:无; 颜色:白色; 填充:10px 22px; 文本对齐:居中; 文字装饰:无; 显示:内联块; 字体大小:14px; 最高:210%; 左:32% } .按钮4{ 背景色:#4CAF50;/*绿色*/ 位置:绝对位置; 边界:无; 颜色:白色; 填充:10px 22px; 文本对齐:居中; 文字装饰:无; 显示:内联块; 字体大小:14px; 最高:220%; 左:31% } .按钮5{ 背景色:#4CAF50;/*绿色*/ 位置:绝对位置; 边界:无; 颜色:白色; 填充:10px 22px; 文本对齐:居中; 文字装饰:无; 显示:内联块; 字体大小:14px; 最高:190%; 左:31% } .按钮6{ 背景色:#4CAF50;/*绿色*/ 位置:绝对位置; 边界:无; 颜色:白色; 填充:10px 22px; 文本对齐:居中; 文字装饰:无; 显示:内联块; 字体大小:14px; 最高:190%; 左:31% } .你好{ 颜色:灰色; 位置:绝对位置; 最高:0.5%; 左:32%; } 你好{ 颜色:灰色; 位置:绝对位置; 最高:17%; 左:22%; } 你好{ 颜色:灰色; 位置:绝对位置; 最高:34%; 左:32%; } 你好{ 颜色:灰色; 位置:绝对位置; 最高:51%; 左:36%; } 你好{ 颜色:灰色; 位置:绝对位置; 最高:67%; 左:35%; } 你好{ 颜色:灰色; 位置:绝对位置; 最高:83%; 左:35%; } 正文{背景色:#5C5858;} h1{颜色:黑色;} /*p{颜色:蓝色;}*/ .矩形{ 高度:40px; 宽度:设备宽度px; 背景色:黑色; } 文件排列门户 要排列文件并运行检查,请单击我! 要从根文件夹整理文件并再次运行检查,请单击我! 要创建PPT和ZIP文件,请单击我! 要复制文件,请单击我! 要粘贴文件,请单击我! 为单个文件运行QC单击我! //console.log();
我刚刚开始学习HTML,我创建了这个UI,我知道这很糟糕,但我想知道如何用更少的代码来改进,以及如何改进外观。我如何用组织更好的代码替换现有的ui 我需要帮助,就像每当用户单击相应的六个按钮时,我想触发大约6个python代码一样。如何改进我的HTML代码并在Php中单击按钮触发python 文件排列门户 /*.第2分部{ 宽度:400px; 背景色:黑色; 高度:100px; 填充:250px; 边框:1px纯灰; 位置:绝对位置; 左:50%; 最高:60%; 转换:转换(-50%,-50%) } p2{ 背景颜色:灰色; 左:100px; 顶部:100px: } */ .按钮1{ 背景色:#4CAF50;/*绿色*/ 位置:绝对位置; 边界:无; 颜色:白色; 填充:10px 22px; 文本对齐:居中; 文字装饰:无; 显示:内联块; 字体大小:14px; 最高:195%; 左:30% } .按钮2{ 背景色:#4CAF50;/*绿色*/ 位置:绝对位置; 边界:无; 颜色:白色; 填充:10px 22px; 文本对齐:居中; 文字装饰:无; 显示:内联块; 字体大小:14px; 最高:210%; 左:33% } .按钮3{ 背景色:#4CAF50;/*绿色*/ 位置:绝对位置; 边界:无; 颜色:白色; 填充:10px 22px; 文本对齐:居中; 文字装饰:无; 显示:内联块; 字体大小:14px; 最高:210%; 左:32% } .按钮4{ 背景色:#4CAF50;/*绿色*/ 位置:绝对位置; 边界:无; 颜色:白色; 填充:10px 22px; 文本对齐:居中; 文字装饰:无; 显示:内联块; 字体大小:14px; 最高:220%; 左:31% } .按钮5{ 背景色:#4CAF50;/*绿色*/ 位置:绝对位置; 边界:无; 颜色:白色; 填充:10px 22px; 文本对齐:居中; 文字装饰:无; 显示:内联块; 字体大小:14px; 最高:190%; 左:31% } .按钮6{ 背景色:#4CAF50;/*绿色*/ 位置:绝对位置; 边界:无; 颜色:白色; 填充:10px 22px; 文本对齐:居中; 文字装饰:无; 显示:内联块; 字体大小:14px; 最高:190%; 左:31% } .你好{ 颜色:灰色; 位置:绝对位置; 最高:0.5%; 左:32%; } 你好{ 颜色:灰色; 位置:绝对位置; 最高:17%; 左:22%; } 你好{ 颜色:灰色; 位置:绝对位置; 最高:34%; 左:32%; } 你好{ 颜色:灰色; 位置:绝对位置; 最高:51%; 左:36%; } 你好{ 颜色:灰色; 位置:绝对位置; 最高:67%; 左:35%; } 你好{ 颜色:灰色; 位置:绝对位置; 最高:83%; 左:35%; } 正文{背景色:#5C5858;} h1{颜色:黑色;} /*p{颜色:蓝色;}*/ .矩形{ 高度:40px; 宽度:设备宽度px; 背景色:黑色; } 文件排列门户 要排列文件并运行检查,请单击我! 要从根文件夹整理文件并再次运行检查,请单击我! 要创建PPT和ZIP文件,请单击我! 要复制文件,请单击我! 要粘贴文件,请单击我! 为单个文件运行QC单击我! //console.log();,python,php,html,Python,Php,Html,我刚刚开始学习HTML,我创建了这个UI,我知道这很糟糕,但我想知道如何用更少的代码来改进,以及如何改进外观。我如何用组织更好的代码替换现有的ui 我需要帮助,就像每当用户单击相应的六个按钮时,我想触发大约6个python代码一样。 提前感谢….要使用PHP运行命令,您应该使用escapeshellcmd(“path To.py”)和shell_exec() 举个例子: echo shell_exec(escapeshellcmd(“路径到.py”) “echo..”输出.py的结果 为了在几分
提前感谢….要使用PHP运行命令,您应该使用escapeshellcmd(“path To.py”)和shell_exec() 举个例子: echo shell_exec(escapeshellcmd(“路径到.py”)代码> “echo..”输出.py的结果 为了在几分钟内实现这一点,您应该将按钮包装成一个表单(如果您不想在地址栏中显示参数,请使用POST),并为其命名为“”。 表单的操作可以为空,action=“”,因此它将刷新实际页面。 然后在页面顶部检查是否有POST,使用if($_POST){}和按下了哪个按钮,使用if($_POST[“赋予按钮的名称”]){}。这只是一个简单的例子。 如果您刚刚开始使用HTML,那么您想要实现的是非常高级的,所以请注意!祝你好运 完整示例:
<?php
// $command=escapeshellcmd("D:\Wamp64\www\demo.py");
// $output=shell_exec($command);
// echo $output;
?>
<html>
<head><meta name="viewport" content="width=device-width, initial-scale=1"><title>File Arrangement Portal</title>
<style>
/* .div2 {
width: 400px;
background-color:black;
height: 100px;
padding: 250px;
border: 1px solid grey;
position:absolute;
left:50%;
top:60%;
transform:translate(-50%,-50%)
}
p2{
background-color: grey;
left:100px;
top:100px:
} */
.button1{
background-color: #4CAF50; /* Green */
position:absolute;
border: none;
color: white;
padding: 10px 22px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 14px;
top:195%;
left:30%
}
.button2{
background-color: #4CAF50; /* Green */
position:absolute;
border: none;
color: white;
padding: 10px 22px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 14px;
top:210%;
left:33%
}
.button3{
background-color: #4CAF50; /* Green */
position:absolute;
border: none;
color: white;
padding: 10px 22px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 14px;
top:210%;
left:32%
}
.button4{
background-color: #4CAF50; /* Green */
position:absolute;
border: none;
color: white;
padding: 10px 22px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 14px;
top:220%;
left:31%
}
.button5{
background-color: #4CAF50; /* Green */
position:absolute;
border: none;
color: white;
padding: 10px 22px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 14px;
top:190%;
left:31%
}
.button6{
background-color: #4CAF50; /* Green */
position:absolute;
border: none;
color: white;
padding: 10px 22px;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 14px;
top:190%;
left:31%
}
.hello{
color:grey;
position:absolute;
top:0.5%;
left:32%;
}
.hello1{
color:grey;
position:absolute;
top:17%;
left:22%;
}
.hello2{
color:grey;
position:absolute;
top:34%;
left:32%;
}
.hello3{
color:grey;
position:absolute;
top:51%;
left:36%;
}
.hello4{
color:grey;
position:absolute;
top:67%;
left:35%;
}
.hello5{
color:grey;
position:absolute;
top:83%;
left:35%;
}
body {background-color: #5C5858;}
h1 {color: black;}
/* p {color: blue;} */
.rectangle {
height: 40px;
width: device-widthpx;
background-color: black;
}
</style></head>
<body>
<div class="rectangle"><h1 style="font-family:Times New Roman;text-align:center";><font color="white">File Arrangement Portal</font></h1></div>
<div style="position: absolute;top:63%; left: 50%;padding:260px;transform:translate(-50%,-50%);width: 450px; height: 100px; background: black; border: 1px solid black">
<h2 class='hello'>To Arrange the files and Run a Check<button class="button button1">Click Me!</button></h2>
<h2 class='hello1'>To Arrange the files from root folder and Run a check again<button class="button button2">Click Me!</button></h2>
<h2 class='hello2'>To Creation of PPT and ZIP File<button class="button button3">Click Me!</button></h2>
<h2 class='hello3'>To Copy the Files<button class="button button4">Click Me!</button></h2>
<h2 class='hello4'>To Paste the Files<button class="button button5">Click Me!</button></h2>
<h2 class='hello5'>Run a QC for Single File<button class="button button6">Click Me!</button></h2>
</div>
<!-- <h1>This is a Heading</h1> -->
<!-- <div class="div2"><p2 style="left:120px; top:100px";><font color="white">Click on one of the text labels to toggle the related control:</font></p2></div> -->
<script>
// console.log(<?php echo $output ?>);
</script>
</body>
</html>
点击我!
欢迎来到堆栈溢出。您将需要一个服务器来运行Python代码,您应该学习如何编写HTML代码,使用flexbox之类的工具来进行布局,而不是绝对定位。这个问题将被否决。详情请阅读
<?php
if($_POST){
if($_POST["button1"]){
echo shell_exec(escapeshellcmd("path to.py"));
}
}
?>
<form action="" method="POST">
<button name="button1" class="button button1">Click Me!</button>
<form>