Interactive applications have been an area of interest for the past few years. But writing one is a trivial affair and needs a lot of effort. In this blog, I will be sharing a tool I made. This tool is an Instagram hashtag generator in Python with a graphical interface and can create any number of Instagram hashtags. We will be using pyqt5 for creating this Instagram hashtag generator.

Why create an Instagram Hashtag Generator in Python?

There are many reasons to use an Instagram Hashtag Generator in Python. For one, Python is a very popular language, so many resources and libraries are available. Additionally, Python is very easy to learn and use, so even if you’re not an experienced programmer, you should be able to get started quickly.

Another reason to use a Python Hashtag Generator is that it can automate the process of finding and using hashtags on Instagram. This can save you a lot of time, especially if you’re managing multiple accounts or running a business on Instagram. Additionally, a Python Hashtag Generator can help you ensure that you’re using the most popular and relevant hashtags for your posts, which can help you get more likes, comments, and followers.



Pyqt5 is a Python binding of the cross-platform GUI toolkit Qt, implemented as a Python plug-in. It helps app developers to use Python to design their own Graphical User Interfaces (GUIs) using a drag-and-drop interface. It offers a comprehensive set of Python bindings for Qt v5. It is implemented as a Python plug-in and can be used in various Qt-based applications. 

The advantage of using Pyqt5 is that it is very easy to use and design GUI interfaces using Python, compared to other languages like C++. It is also cross-platform, meaning that it can be used on a variety of operating systems, including Windows, Linux, and macOS.

To install pyqt5 use the following code in the terminal:

pip install pyqt5

To install QT designer go to the following link then install the software:

Step 1: launch the qt designer and setup the graphical interface

  1. Add the vertical layout and then lay it out vertically in the layout option.
  2. Add a horizontal layout
  3. Add a push button at the bottom
  4. Add two new vertical layouts to the horizontal layout

The window should be looking like this

  1. Add a new button in each vertical layout
  2. Then add a new label in each vertical layout
  3. Now add a new list view in the first vertical layout
  4. Add a new tree view in the second vertical layout

The window should be looking like this

  1. Now add the new menu with the file 
  2. Then add save and load in the file menu

The window should look like this

  1. Change the single selection mode to multi selection mode in the qabstractionitme view
  2. At this point, we can rename all the labels and buttons of the interface.
  3. And if you want to, you could also try changing your font size or font family for a better appearance in the qabstraction view.

Step 2: Create a new python file and code

Note: don’t forget to check the object name of your qt app because it can be different from mine.

from PyQt5.QtWidgets import *
from PyQt5.QtGui import QFont
from PyQt5 import uic
from PyQt5.Qt import QStandardItemModel, QStandardItem
import pickle
import json
# We need to import json because we are importing the hashtags from a json file.

# lest create mygui class

class MyGUI(QMainWindow):

    def __init__(self):
        super(MyGUI, self).__init__()
        uic.loadUi('hastag.ui', self)

        # set the title
        self.setWindowTitle("hastag genrator")
        # then initialize the dictionary with json file
        self.hastag_dict = json.load(open('text.json'))

        self.slected = []

        self.list_model = QStandardItemModel()


    def init_tree_view(self):

        # define model
        self.tree_model = QStandardItemModel()

        root_node = self.tree_model.invisibleRootItem()

        for category in self.hastag_dict.keys():
            category_item = QStandardItem(category)
            for hastag in self.hastag_dict[category]:


    def choose_selected(self):
        if len(self.treeView.selectedIndexes()) != 0:
            for index in self.treeView.selectedIndexes():
                if index.parent().isValid():
                    if not in self.slected:

    def remove_selected(self):
        if len(self.listView.selectedIndexes()) != 0:
            for index in reversed(sorted(self.listView.selectedIndexes())):

    def copy_to_clipboard(self):
        if (len(self.slected) != 0):
            clipboard = QApplication.clipboard()
            clipboard.setText('#' + '#'.join(self.slected))

    def save_hashtag(self):
        filename, confirmed = QFileDialog.getSaveFileName(self, 'Save Hashtag', '', 'Tag File (*.tags)')
        if confirmed:
            with(open(filename, 'wb')) as f:
                pickle.dump(self.selected, f)

    def load_hashtag(self):
        filename, confirmed = QFileDialog.getOpenFileName(self, 'Load Hashtag', '', 'Tag File (*.tags)')
        if confirmed:
            with (open(filename, 'rb')) as f:
                self.selected = pickle.load(f)
            self.list_model = QStandardItemModel()
            for tag in self.selected:

app = QApplication([])
window = MyGUI()


  1. Import all the dependencies
  2. Created my GUI class and added all the buttons labels listview and treeview.
  3. Imported hashtags from the JSON files.
  4. Defined the treeview and listview.
  5. Then defined the select and remove function of a hashtag
  6. Defined the function of all three buttons.


After running the app all the functions all working fine like selecting the hashtags, copying to the clipboard, saving the file, and loading the file.

Final Words

The Instagram hashtag generator is a tool that can be used by anyone. It’s really easy to use and even the most tech-savvy users will have an easy time making professional-looking hashtags for their photos! In order to make these hashtags, first, you pick a category. Then you decide how many hashtags you want to generate then it will convert them into strings of hashtags that you can copy into Instagram or any social media post. We hope you had fun making your hashtags and don’t forget to comment below if you have any questions.