MrDevKnown

SELECT * FROM world WHERE humanity IS NOT NULL;

  • Home
  • About
  • Contact Us
PyQt5 is a very powerful python gui development framework. This post shows the complete installation and setup of PyQt5 with qt designer tool.

First you need to install Python for this. ALso, make sure the the path is added to the path vatiables. Then open the Windows terminal, cmd and type pip and press enter. If it shows an error then that means, python is not added to path. If it works, then follow the below steps to install and setup pyqt5.



PyQt5 Installation Setup


$ pip install pyqt5

Type the above code in Windows terminal and press Enter key. Wait for the installation

PyQt5 Tools Setup


$ pip install pyqt5-tools

This code will install PyQt5 tools such as qt designer to make the gui.

Qt Designer path

C:\Users\$Username$\AppData\Local\Programs\Python\Python39\Lib\site-packages\qt5_applications\Qt\bin



Note: Edit the $username$ with your username in the above path.

This is how the qt designer window looks like...
Qt designer mrdevknown tutorial. Setup PyQt5 and install qt designer for python.


So, I think that's it for this post... See you in the next.

When you are working with PyQt5, you are using the default OS style of application. The design looks very simple for apps. So, if you are making a cutom app, you will cuystomise the top bar in few cases to have a better design. So, when you are customising the design, you will see that the window has no longer been movable. Thus, you need to write the logic to make the window movable again.
The default Window app style looks like this

The code for doing this is given below...

PyQt5 draggable window Code

Further Reading













.ui to .py file conversion
Qt designer is a designer for GUI. We can designs in it and then save them as a .ui file. When you are working with PyQt5 for making GUI in python, you have to export the .ui file to a .py file. We can do this by using qt-tools. pyuic5 command is used in Python to do this. Go to the path where the ui is saved and enter the below command.

pyuic5 command to convert .ui to .py


$ pyuic5 xyz.ui -o xyz.py

Note: Edit the xyz.ui with the UI file name and xyz.ui with the python file name you want to give to the design in the above command.


To setup complete PyQt5 with Qt tools and install Qt Designer,
Click here

So, I think that's it for this post... See you in the next.
When you are working with PyQt5, you are using the default OS style of application. The design looks very simple for apps. So, if you are making a cutom app, you will cuystomise the top bar in few cases to have a better design. So, when you are customising the design, you will see that the window has no longer been movable. Thus, you need to write the logic to make the window movable again.
The default Window app style looks like this

The code for doing this is given below...

PyQt5 draggable window Code


class movable(QtWidgets.QWidget):
    def __init__(self):
        super(movable, self).__init__()
    def mousePressEvent(self, event):
        if event.button() == QtCore.Qt.LeftButton:
            self.dragPosition = event.globalPos() - self.frameGeometry().topLeft()
            event.accept()
    def mouseMoveEvent(self, event):
        if event.buttons() == QtCore.Qt.LeftButton:
            self.move(event.globalPos() - self.dragPosition)
            event.accept()

You will have to first make a class like this. Then you have to pass the class as parameter in the main window code. Like this...


class mainWindow(movable, Ui_Form):
    def __init__(self):


Here UI form is the form of the design.

So, I think that's it for this post. See you in the next...

Make your own Python IDE + Text Editor like Notepad:

July 17, 2021, 4:33:43 PM (MrDev in a deep thought)

If you have used Python, you must be aware of the Python shell (the IDLE). We have one place where we write the code and to run the code, we need to switch between the windows. Some brilliant mind will say (with a sarcastic sound) "He calls himself a programmer and he is talking about IDLE... Lol hahaha."

Shut up! Okay? I use IDEs but something that you have made, even its worse than what you think that was worse, you will like that! And a programmer builds things. This is his work.

Now in this project, I created my own IDE with python using Tkinter.

Now let me assume that some of you are from Mars and they don't know what IDEs actually are? So basically, IDE stands for Integrated Development Environment. It provides a collection of different things needed for coding and creates an environment for coding fast. Well its obvious that I could not make something at once that can directly challenge VS code (one of the leading IDEs in). But I can make something more similar to a text editor (like Notepad). And basically, what we actually want in programming is a section to run the program and display the output. So, can't we combine the output and the editor part in the same window. So, it reduces our work to switch between the windows like we do in IDLE.

Well, that's all about the idea. I am going to create a new notepad. But don't laugh. Okay. It would have some more features than notepad. Believe me! Let's start!

>>> Test 1: ✔
>>> Test 2: ✔
>>> Test 3: ✔
>>> Test 4: ✔
...

Code Link
Make your own Web Browser in Python using PyQt5. PyQt5 is a very powerful Python framework to make modern GUIs. With help of Python PyQt5 QtWebWidgets, it is very easy to amke your own custom web browser with a few lines of code.

PyQt5 Basic code


import sys
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *

class MainWindow(QMainWindow):
    def __init__(self):
        # Main Window
        super(MainWindow, self).__init__()
        self.showMaximized()

app = QApplication(sys.argv)
QApplication.setApplicationName("Browser")
window = MainWindow()
app.exec_()



PyQt5 Browser code using QtWebEngine


import sys
from PyQt5.QtCore import *
from PyQt5.QtWidgets import *
from PyQt5.QtWebEngineWidgets import *

class MainWindow(QMainWindow):
    def __init__(self):
        # Main Window
        super(MainWindow, self).__init__()
        self.browser = QWebEngineView()
        self.browser.setUrl(QUrl('https://google.com'))
        self.setCentralWidget(self.browser)
        self.showMaximized()

        # nav bar
        navBar = QToolBar()
        self.addToolBar(navBar)

        backBtn = QAction("Back", self)     # back Button
        backBtn.triggered.connect(self.browser.back)
        navBar.addAction(backBtn)

        forwardBtn = QAction("Forward", self)   # forward Button
        forwardBtn.triggered.connect(self.browser.forward)
        navBar.addAction(forwardBtn)

        relBtn = QAction("Reload", self)    # Reload Button
        relBtn.triggered.connect(self.browser.reload)
        navBar.addAction(relBtn)

app = QApplication(sys.argv)
QApplication.setApplicationName("Browser")
window = MainWindow()
app.exec_()



The final look of the browser after the above code.
Make your own Web Browser in Python - Python PyQt5 tutorial - QtWebEngineWidgets


So, I think that's it for this post. See you in the next...

Make your own Python IDE + Text Editor like Notepad:

July 17, 2021, 4:33:43 PM (MrDev in a deep thought)

If you have used Python, you must be aware of the Python shell (the IDLE). We have one place where we write the code and to run the code, we need to switch between the windows. Some brilliant mind will say (with a sarcastic sound) "He calls himself a programmer and he is talking about IDLE... Lol hahaha."

Shut up! Okay? I use IDEs but something that you have made, even its worse than what you think that was worse, you will like that! And a programmer builds things. This is his work.

Now in this project, I created my own IDE with python using Tkinter.

Now let me assume that some of you are from Mars and they don't know what IDEs actually are? So basically, IDE stands for Integrated Development Environment. It provides a collection of different things needed for coding and creates an environment for coding fast. Well its obvious that I could not make something at once that can directly challenge VS code (one of the leading IDEs in). But I can make something more similar to a text editor (like Notepad). And basically, what we actually want in programming is a section to run the program and display the output. So, can't we combine the output and the editor part in the same window. So, it reduces our work to switch between the windows like we do in IDLE.

Well, that's all about the idea. I am going to create a new notepad. But don't laugh. Okay. It would have some more features than notepad. Believe me! Let's start!

>>> Test 1: ✔
>>> Test 2: ✔
>>> Test 3: ✔
>>> Test 4: ✔
...

Code Link
React JS custom text editor modal component.

    
        
import React, { useState } from 'react'

export default function Form() {
    const clear = () => {
        let newtext = text.substr(0, -1);
        setText(newtext);
    }
    const copy = () => {
        navigator.clipboard.writeText(text)
    }
    const upper = () => {
        let newtext = text.toUpperCase();
        setText(newtext);
    }
    const capitalize = () => {
        let newtext = text.charAt(0).toUpperCase() + text.slice(1);
        setText(newtext);
    }
    const remove_space = (event) => {
        let newtext = text.split(' ').filter(s => s).join(' ');
        setText(newtext);
    }
    const handleOnChange = (event) => {
        setText(event.target.value);
    }
    const [text, setText] = useState("");
    return (
        <>
            <div classname="form-group container p-4">

                {/* buttons */}
                <button 0="" classname="btn  btn-primary" data-bs-placement="top" data-bs-toggle="tooltip" disabled="{text.length" onclick="{clear}" title="Tooltip on top"><i classname="far fa-trash-alt"></i></button>
                <button 0="" classname="btn  btn-primary" disabled="{text.length" onclick="{copy}"><i classname="far fa-copy"></i></button>
                <button 0="" classname="btn  btn-primary" disabled="{text.length" onclick="{upper}"><i classname="far fa-text-size"></i></button>
                <button 0="" classname="btn  btn-primary" disabled="{text.length" onclick="{capitalize}"><i classname="fas fa-font-case"></i></button>
                <button 0="" classname="btn btn-primary" disabled="{text.length" onclick="{remove_space}"><i classname="fas fa-line-height fa-rotate-270"></i></button>

                {/* Textarea */}
                <textarea classname="thetext form-control mb-4" id="exampleFormControlTextarea1" onchange="{handleOnChange}" rows="8" value="{text}"></textarea>
                <h4 classname="mt-4">Text Count</h4>
                <div classname="my-2">
                    <p>{text.split(/\s+/).filter((element) =&gt; { return element.length !== 0 }).length} words and {text.split(' ').filter(s =&gt; s).join('').length} characters</p>
                </div>
            </div>
        &lt;/&gt;
    )
}

        
        
        
How to Learn React Step by Step:
React JS is a very popular web framework. It is a free and open-source front-end JavaScript library for building user interfaces or UI components. React JS is maintained by Facebook. So, if you are a web developer, you should be aware that everythin gwe see on the web is just html, css and the functioning things are simply javascript. You must have worked with html and css to make simple websites or standalone pages. But, what if you are building a large commercial website with many pages. There are a lot things to know about web development and many compplexitie4s in doing them like routing without reloading the pages.

So, React makes things much more easier and developer friendly to handle. Thus for a modern UI developer, you should learn this. Not only for UI, React helps in making a complete web app structure. This is not just for React. There are other JS libraries also like Angular, that you can learn to create modern web apps. But, in this post, we are discussing about React JS... Further Reading
Make a working Navbar component in react.

First import the links

    
        
<link crossorigin="anonymous" href="https://cdn.jsdelivr.net/npm/bootstrap@5.1.1/dist/css/bootstrap.min.css" integrity="sha384-F3w7mX95PdgyTmZZMECAngseQB83DfGTowi0iMjiWaeVhAn4FJkqJByhZMI3AhiU" rel="stylesheet"></link>
<link crossorigin="anonymous" href="https://pro.fontawesome.com/releases/v5.10.0/css/all.css" integrity="sha384-AYmEC3Yw5cVb3ZcuHtOA93w35dYTsvhLPVnYs9eStHfGJvOvKxVfELGroGkvsg+p" rel="stylesheet"></link>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.5.1/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.16.0/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.2/js/bootstrap.min.js"></script>
        



React

    
        
import React from 'react'
import { Link } from 'react-router-dom'

export default function Navbar() {
    return (
        &lt;&gt;
            <nav classname="navbar navbar-expand-md bg-light navbar-light">
                <link classname="navbar-brand" to="/"></link>Social
                <button classname="navbar-toggler" data-target="#collapsibleNavbar" data-toggle="collapse" type="button">
                    <i classname="fal fa-bars"></i>
                </button>
                <div classname="collapse navbar-collapse" id="collapsibleNavbar">
                    <ul classname="navbar-nav">
                        <li classname="nav-item">
                            <link classname="nav-link" to="/"></link>Home
                        </li>
                        <li classname="nav-item">
                            <link classname="nav-link" to="/about"></link>About
                        </li>
                    </ul>
                    <div classname="d-flex navbar-nav">
                        <li>
                            <link classname="nav-item btn-danger btn mx-3" to="/login"></link>Login
                        </li>
                        <li>
                            <link classname="nav-item btn border border-primary" to="/"></link>Sign Up
                        </li>
                    </div>
                </div>
            </nav>
        &lt;/&gt;
    )
}


How to Learn React Step by Step:
React JS is a very popular web framework. It is a free and open-source front-end JavaScript library for building user interfaces or UI components. React JS is maintained by Facebook. So, if you are a web developer, you should be aware that everythin gwe see on the web is just html, css and the functioning things are simply javascript. You must have worked with html and css to make simple websites or standalone pages. But, what if you are building a large commercial website with many pages. There are a lot things to know about web development and many compplexitie4s in doing them like routing without reloading the pages.

So, React makes things much more easier and developer friendly to handle. Thus for a modern UI developer, you should learn this. Not only for UI, React helps in making a complete web app structure. This is not just for React. There are other JS libraries also like Angular, that you can learn to create modern web apps. But, in this post, we are discussing about React JS... Further Reading
Make a text typing Animation in JavaScript.


HTML Code

    
        
<div class="top-wrapper">
	<p>
        </p><h2 class="txt-rotate" data-period="900" data-rotate="[&quot;Hello User&quot;, &quot;Welcome to MrDevKnown&quot;, &quot;JavaScript Tuorial&quot;, &quot;Text typing effect in JS&quot;]">
        </h2>
	<p></p>
</div>
    



JavaScript Code


var TxtRotate = function (el, toRotate, period) {
        this.toRotate = toRotate;
        this.el = el;
        this.loopNum = 0;
        this.period = parseInt(period, 10) || 2000;
        this.txt = '';
        this.tick();
        this.isDeleting = false;
    };

    TxtRotate.prototype.tick = function () {
        var i = this.loopNum % this.toRotate.length;
        var fullTxt = this.toRotate[i];

        if (this.isDeleting) {
            this.txt = fullTxt.substring(0, this.txt.length - 1);
        } else {
            this.txt = fullTxt.substring(0, this.txt.length + 1);
        }

        this.el.innerHTML = '' + this.txt + '';

        var that = this;
        var delta = 300 - Math.random() * 100;

        if (this.isDeleting) { delta /= 2; }

        if (!this.isDeleting && this.txt === fullTxt) {
            delta = this.period;
            this.isDeleting = true;
        } else if (this.isDeleting && this.txt === '') {
            this.isDeleting = false;
            this.loopNum++;
            delta = 500;
        }

        setTimeout(function () {
            that.tick();
        }, delta);
    };

    window.onload = function () {
        var elements = document.getElementsByClassName('txt-rotate');
        for (var i = 0; i < elements.length; i++) {
            var toRotate = elements[i].getAttribute('data-rotate');
            var period = elements[i].getAttribute('data-period');
            if (toRotate) {
                new TxtRotate(elements[i], JSON.parse(toRotate), period);
            }
        }
        // INJECT CSS
        var css = document.createElement("style");
        css.type = "text/css";
        css.innerHTML = ".txt-rotate > .wrap { border-right: 0.08em solid #666 }";
        document.body.appendChild(css);
    };

JavaScript Music Player Web App:
That was 26 July, 2021. I wanted to improve my front end development skills. So I decided to make something that would also help me in Javascript. Because seriously, I am worse at it! At the end, I sat on my computer and started looking for an idea. Suddenly, I don't know why but one line said by Mark Zuckerberg hit me on my mind. Mark has once said during his speech at Harvard, "Facebook was not the first thing that I built... I also built games, chat systems, study tools and music players. I’m not alone. JK Rowling got rejected 12 times before publishing Harry Potter. Even Beyonce had to make hundreds of songs to get Halo. The greatest successes come from having the freedom to fail."

Well I know that's very motivating line... But I am not talking about that! Well, I know you got what I am talking about, but I need to explain this... 

Did you notice, he said Music Players... Well, That's where the idea came from... Thank you Zuck! :)

So, first things first, I did what's every web dev's first step, that is to create a index.html file... Then it all started... Firstly I created the basic structure of the website in html then added some css in it... Further Reading 


Newer Posts Older Posts Home

ABOUT ME

Web developer, designer. A self taught programmer. Don't hesitate to come for say a small "hello!"
Shivesh Tiwari

POPULAR POSTS

  • Make a Windows 11 themed Website - HTML, CSS Windows 11 design
  • How to test your typing speed with Python - Make a Python app
  • How to make Windows 11 Website Design | Adding Working App Windows | Dark Mode and other things
  • PyQt5 draggable Custom window code
  • How to count number of words in javascript - Using UseState React Tutorial
  • How to make my own web Browser
  • Qt Designer UI to python file export
  • Python PyQt5 complete Setup Windows
  • React JS Custom Text Editor Modal Component
  • How to make an ASCII spinning Donut in Python - Python PyGame tutorial

Categories

  • best javascript project 12
  • code 5
  • dino game 1
  • dislike 1
  • easy python projects 9
  • flask 1
  • free python code 10
  • game 2
  • git 1
  • github 1
  • hack 2
  • hack chrome dino game 1
  • hack game 1
  • html best website 4
  • javascript website 6
  • learn javascript 9
  • learn programming 13
  • learn python 15
  • like 1
  • like dislike system php 1
  • mrdevknown 5
  • music player 1
  • notification 1
  • php 2
  • programming 9
  • project 9
  • pyqt5 4
  • python 16
  • python IDE 2
  • python projects 8
  • React 5
  • react js 6
  • software 5
  • Tkinter 2
  • web app 4
  • website 4
Powered by Blogger
MrDevKnown

Search This Blog

Archive

  • August 20231
  • March 20231
  • December 20221
  • September 20222
  • August 20221
  • June 20221
  • March 20221
  • January 20226
  • December 20211
  • November 20213
  • October 202111
  • September 20213
  • August 20213
Show more Show less
  • Home
  • About
  • Contact Us

Subscribe

Posts
Atom
Posts
All Comments
Atom
All Comments

Subscribe

Posts
Atom
Posts
All Comments
Atom
All Comments

Categories

  • React5
  • Tkinter2
  • best javascript project12
  • code5
  • dino game1
  • dislike1
  • easy python projects9
  • flask1
  • free python code10
  • game2
  • git1
  • github1
  • hack2
  • hack chrome dino game1
  • hack game1
  • html best website4
  • javascript website6
  • learn javascript9
  • learn programming13
  • learn python15
  • like1
  • like dislike system php1
  • mrdevknown5
  • music player1
  • notification1
  • php2
  • programming9
  • project9
  • pyqt54
  • python16
  • python IDE2
  • python projects8
  • react js6
  • software5
  • web app4
  • website4

Translate

Pages

  • Home
  • Privacy Policy

Popular Posts

Music Player web app made in HTML, CSS, Javascript

Music Player web app made in HTML, CSS, Javascript

August 03, 2021
Top must have windows software for a developer

Top must have windows software for a developer

September 17, 2022
Javascript code to display a welcome message after accepting the name of the user using a prompt box

Javascript code to display a welcome message after accepting the name of the user using a prompt box

August 20, 2022

Trending Articles

  • Make a Windows 11 themed Website - HTML, CSS Windows 11 design
  • How to test your typing speed with Python - Make a Python app
  • How to make Windows 11 Website Design | Adding Working App Windows | Dark Mode and other things
  • PyQt5 draggable Custom window code

Popular Posts

  • PyQt5 draggable Custom window code
  • Qt Designer UI to python file export
  • Python PyQt5 complete Setup Windows

Labels

Distributed By Gooyaabi | Designed by OddThemes