I am beginner in python and stackoverflow
I am going to make a better desplay using python. I have a ubuntu on beaglebord. I want to make a good display(It only desplays some datas interactively - It gives some output only, no input gui interaction is provided) using python. I here about pyqt. But I don't know is it ok to design a better dashboard in my case. Is it possible to connect with a minimal browser(like what do in ATM's) desplay using python. So that I can design it using HTML and CSS.
please help me
You can design your UI using HTML and CSS. You must use pyQT's QWebView control to display these html pages as below
dashboard = QWebView()
dashboard.load("dashboard.html")
dashboard.show()
Related
Supose I have a python game and I want to "post" it on a site like Friv that I am making. Is there any way
for me import the "game.py" to the "site.html" and it show when I enter the site? I made a search and found to use django, but I would need to pass all the html code that I already have to other aplication.
The language of browsers is JavaScript.
There is a project called PyJs which translates Python code to JavaScript and is useful in your case that you want to run Python code inside web browsers.
Finally you can use your resulting JavaScript files to fill up your HTML page.
In addition to PyJs, there are numerous other projects that "run Python code in a browser" like Brython. However, any of them have not been standardized and if you want a robust game in your browser, use JavaScript!
There are number of projects that compile python into JavaScript in order to be run on browser.
Here are two links that might help
Web Browser Programming: https://wiki.python.org/moin/WebBrowserProgramming
PyGame Trinket: https://trinket.io/features/pygame
The way I integrate python code in an html is to use templating language like jinja2 but if you want to write full python code in html then use need to use a transpiler like PyJS but since you want to integrate the same code in multiple program, why not use FLASK it is much more easier.
and make an api. Django is an option but it has a steep learning curve. you can make the UI using HTML and get the data from python using API.
My Google search skills evidently aren't up to scratch, so I'm wondering if Django has the capability to dynamically update text displayed on the HTML page depending on what option is selected from a dropdown?
Or would I need to look into utilising another tool to help with this?
Apologies for the noob question as I'm still learning Python/Django.
This can only be achieved via frontend scripting, so JavaScript. Depending on what you are using in your templates, you might have a possibility to use that library or write javascript yourself.
I think the easiest is to write it yourself. You could do it in the following way:
Create <div id="?">...</div> and populate with relevant text for all your options (change id="?" appropriately)
Show only the default one and hide the other
if you are using bootstrap[345] you can apply classes (d-none vs d-block)
write your own javascript
Then tie a "click" on the dropdown method to the activation of corresponding <div>
With the amount of information you supplied us with, this is the most I can suggest to you. I hope I interpreted your question correctly.
I am trying to transfer an app i build in R Shiny to Python Code.
It's main use is to set the input parameters for a data analysis to be run which should create and output pdf file.
So far I managed to understand that DASH might be the tool to go with. But is there a way to launch a DASH app in an external window (not in a browser window)? Like the following:
After setting the Input values I want to have a button to click "Run" or something similiar to run the underlying code and generate a PDF Report. How would you do that with Python and do you maybe know a good Tutorial how to build a basic app like this?
I'm not exactly sure what you mean in the first part of your question. You may be able to use an IDE with integrated broswer to view your app during developement if you don't want to use a broswer. But the whole point of dash is to be a web based application, so it would be best on a browser.
Alternately, you can save the rendered output from browser to a .html file if you need to share it without having a live server host your application.
For the second part of your question, for a button click to generate a pdf report, refer to the documentation of callback in dash.
The callback function for the Run Analysis button can then be something on the lines of
def generate_report():
#Code to generate required pdf
# Code to download on client
return link_to_pdf
Hope this gives some pointers in the direction.
I have an interactive graph generated by Plotly in Python that I saved to an html file using plotly.offline.plot(fig, filename='/tmp/interactiveGraph.html')
I am now trying to embed this interactive graph into some kind of webpage, using either Dash or Django. I'm leaning toward Django at the moment, given that I have an html version of the graph. Which would be better?
My code for the webpage is in a separate file from the code where I am creating the graph.
A lot of the tutorials I've found online just say to add a few lines to the template, but I don't know how to get those lines that they've described.
tl;dr: I'm looking for guidance as how to integrate an html file-for a Plotly interactive graph-with a web python script using Django or Dash
Side Question:
what is the difference between
plotly.offline.plot(fig, include_plotlyjs=False, output_type='div')
and what I have above?
Reference:
https://github.com/ricleal/DjangoPlotLy
https://www.pythonsetup.com/how-implement-data-visualization-django-and-plotly/
I would highly reccomend Django, its a great framework. As for this, the best option is to generate the data via JavaScript and Plotly has a great library for this. If you must use python, then Django can be used. Assuming you are familiar with Django, inside of your view you can collect your data and build your graph ( I would reccomend a celery task for something long running like this unless they are small graphs), and you can then collect the return from creating the graph in div format. This will return a string that holds all the needed html and css for the graphs. Put this inside of you get_context_data() method in your view and place it into the dictionary. You can the use that object inside of a template. I have done this before, if you are having a hard time feel free to DM me. Hope this helps some!
In regards to your side question, I believe having False for including JS will make the graph a bit smaller assuming you have an include for the plotly JS library. They might have done this in a newer release to make the graphs faster as they were significantly slower in the browser from python that the JS rendered one.
So far I have only been taught how to program/script at my school for console programs but wanted to start making some applications with an actual interface other then the command-line, unfortunately I have no idea where to begin. I tried to look it up but all I found were guides on how to "design" them not program them. As such I would like to ask you how exactly should I get started on this, I know this is a rather broad question but just a few links to some study material that can help me get started is enough. The languages I have been taught are Visual Basic and Python but I also know HTML and CSS, I am only slightly familiar with JavaScript.
(Bonus Question: so when looking at the website for Atom.io I saw that the editor was made in JavaScript, node.js, HTML and CSS. I was wondering how did they use HTML and CSS for a desktop app? Also, is it possible to do that without node.js and JavaScript, say for example with Python?)
Recommend begin with:
Visual Basic: Windows Forms(have a nice GUI editor, easier than TkInter)
Python: TkInter(Everything simple with pack()).
About HTML/CSS/JS desktop app use Electron http://electron.atom.io/
Given you already know python , you can use python library "Tkinter" to get started.
https://www.tutorialspoint.com/python/python_gui_programming.htm
https://wiki.python.org/moin/TkInter
Have a look at Graphics Py document created by John Zelle
http://mcsp.wartburg.edu/zelle/python/graphics/graphics.pdf