Code Monkey home page Code Monkey logo

pyside-db-chart-mapping-example's Introduction

pyside-db-chart-mapping-example

PySide6 example of mapping database table(QSqlTableModel based tableview) and chart with QVBarModelMapper.

All basic CRUD feature of database mapped into chart(QChartView).

You can save the chart as image/pdf file, you can see the saved file over here.

You can find out more features and usages below.

Requirements

  • PySide6

Packages which will be automatically install (All of them are related to import/export as excel feature)

  • xlsxwriter - export as excel
  • pandas - import as excel
  • openpyxl - import as excel

Note: pandas maybe requires more packages than above such as daas.

Setup

python -m pip install git+https://github.com/yjg30737/pyside-db-chart-mapping-example.git --upgrade

If you don't want to import/export excel feature and install related libraries

python -m pip install git+https://github.com/yjg30737/pyside-db-chart-mapping-example.git@7d204961cd7462266ab15a20e9c0a62c40ab74fc

Usage/Feature

  • If you want to delete more than one record, holding ctrl and select records one by one or holding shift and select records as consecutive range.
  • If you change the data in table, chart data will be changed as well. Try changing name, score 1~3 fields or adding/deleting the record. It works like a charm.
  • 4 records are given by default to show how it works.
  • You can search the text in table with writing the text in search bar. Table will show the matched records, chart will be not influenced by search bar.
  • ID cell can't be editable which is supposed to be like that, you can write number only to score 1~3 columns.
  • You can save the chart as an image/pdf file.
  • If you put the mouse cursor on the bar, barset's border color will be changed. If you select/click one of the bar, its background color will be changed and text browser will show the bar's info. If cursor leaves, border color will be restored as normal.
  • You can change each color of the bar, choose to set the animation of chart in the settings dialog.
  • Import/export excel file
  • Being able to view the table info

Example

from PySide6.QtWidgets import QApplication
from pyside_db_chart_mapping_example.main import Window


if __name__ == "__main__":
    import sys

    app = QApplication(sys.argv)
    window = Window()
    window.show()
    sys.exit(app.exec())

Result

python_example

You don't have to care about left check box list. I'm still working on it.

image

If you place the mouse cursor on one of the bar, barset border's color will be changed as i mentioned before. In this case, border color turns to be red.

Click the bar will change the bar's background color and show the bar's basic info on the text browser. In this case, background color turns to be green.

See Also

Note

I'm struggling with the problem that item is not added more than one after table was empty.

After much research i convince this is gotta be glitch.

Don't want to report this to Qt however. Someone please do it for me.

I just want to figure it out on my own.

Another glitch i found is that you have to add more than one if you add 1 to the last column of the mapper(QVBarModelMapper).

self.__mapper.setLastBarSetColumn(self.__mapper.lastBarSetColumn()+2)

I don't even know what's going on here.

pyside-db-chart-mapping-example's People

Contributors

yjg30737 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.