コード例 #1
0
ファイル: bundle.py プロジェクト: genexu/ptt-follower
 def __init__(self):
     super(Bundle, self).__init__()
     self.header = Header()
     self.body = Body()
     self.footer = Footer()
     self.status = NORMAL
     self.output = urwid.Frame(self.body.output,
                               header=self.header.output,
                               footer=self.footer.output,
                               focus_part='body')
コード例 #2
0
def Dataset_documentation():
    nav = Navbar()
    footer = Footer()

    body = dbc.Container(
        [
            dbc.Row([
                dbc.Col([
                    html.H2(
                        "COVID-19 Aggregated Clinical Dataset Documentation"),
                    html.
                    P('As policy makers and healthcare professionals tackle the COVID-19 pandemic, a critical factor inhibiting effective decision making at regional, national, and global levels is a lack of relevant data on patient outcomes. We hope to partially alleviate this problem by sharing the following dataset, which aggregates data from over 160 published clinical studies and preprints released between December 2019 and April 2020. For each paper, an MIT researcher read the paper and gathered relevant numerical data from tables and from the text into a standard format.'
                      ),
                    html.
                    P('We would like to remind the reader that the raw data in this dataset should not be used to estimate trends in the general population such as mortality rates. Indeed, this dataset is largely derived from studies run in hospitals and nations affected with SARS-COV-2 generally only admit seriously affected patients to hospitals. However, it should be possible to derive reasonably accurate estimates of these quantities by (a) accounting for the prevalence of asymptomatic patients, and (b) only including sufficiently representative studies.'
                      ),
                    html.
                    P('At a high level, each row of the dataset represents a cohort of patients. Some papers study a single cohort, while others study several cohorts, and still others report results about one cohort and one or more subcohorts; all of these are included as rows in the dataset. Given a cohort, each column represents information about this cohort of patients, divided roughly in the following categories:'
                      ),
                    dcc.Markdown('''
						1. demographic information (e.g. number of patients in the cohort, aggregated age and gender statistics)
						2. comorbidity information (e.g. prevalence of diabetes, hypertension, etc.)
						3. symptoms (including fever, cough, sore throat, etc.)
						4. treatments (including antibiotics, intubation, etc.)
						5. standard labs (including lymphocyte count, platelets, etc.)
						6. outcomes (including discharge, hospital length of stay, death, etc.)
						'''),
                    html.
                    P('This database aggregates reported data from different hospitals across the world, which may have different equipment and reporting standards. It was obtained through a human reading process, which is inherently imperfect. In addition, we often chose to prioritize standardizing information across papers over perfect accuracy. We list some important observations about the data below.'
                      ),
                    dcc.Markdown('''
						1. The data in this spreadsheet includes data from preprints which have not yet been subject to peer review. We have chosen to include these studies because the additional predictive power from having 2-3 times more data outweighs the potential for errors in these data points. However, we remind the reader that caution should be taken when using data which has not yet been subject to peer review.
						2. To minimize human error in data reporting, we have verified some key features with additional scrutiny, including mortality, ICU and hospital length of stay, key symptoms (fever, cough, short breath, fatigue, diarrhea) and common comorbidities (hypertension, diabetes).
						3. Across papers, subcohort divisions may follow different criteria (which may be of independent interest), including: severity of disease (severe vs. mild), death (survivors vs. non-survivors), treatment (intubation vs. non-intubation), comorbidity (diabetic vs. non-diabetic).
						4. Papers are not consistent on their reporting of mortality or discharge rates. Some only report mortality; others report only discharges; many patients remain in the hospital at the conclusion of the study.
						5. Studies in this dataset do not always have the same purpose, which affects data reporting. For instance, many papers from Italy seem to report data only on non-survivors. In addition, some studies focus on the disease’s contagion profile, with little information on death, discharge, stay length. Data points from these studies may exhibit a high proportion of missing features.
						6. To the best of our ability, we avoid reporting data from metastudies to avoid double-counting patients. However, there remains a (low) risk that some patients will appear in multiple studies (for example two studies in Feb and Mar in the same hospital).
						7. We have tried to report all lab values in consistent units. We have included a companion document (Reference Ranges) with corresponding reference ranges to facilitate analysis. There are some instances where the reported lab units seem inconsistent with the expected ranges (e.g. for D-Dimer), but we have generally reported the raw values from the source papers.
						'''),
                    html.
                    P('To cite the dataset, you can use the following reference:'
                      ),
                    dcc.Markdown('''
						@online{bertsimas2020covidClinicalOutcomes,
						author = {Bertsimas, Dimitris and Bandi, Hari and Boussioux, Leonard and Cory-Wright, Ryan and Delarue, Arthur and Digalakis, Vasileios and Gilmour, Samuel and Graham, Justin and Kim, Adam and Lahlou Kitane, Driss and Lin, Zhen and Lukin, Galit and Li, Michael and Mingardi, Luca and Na, Liangyuan and Orfanoudaki, Agni and Papalexopoulos, Theodore and Paskov, Ivan and Pauphilet, Jean and Skali Lami, Omar and Sobiesk, Matthew and Stellato, Bartolomeo and Carballo, Kimberly and Wang, Yuchen and Wiberg, Holly and Zeng, Cynthia},
						title = {An Aggregated Dataset of Clinical Outcomes for COVID-19 Patients},
						url = {http://www.covidanalytics.io/dataset_documentation},
						year={2020}
						}'''),
                    #8. We intend to continuously update this dataset, for the duration of this epidemic. If you spot any errors in the dataset, or know of any papers which you believe this dataset would benefit from including, please do not hesitate to contact us, either by filing an issue in our GitHub repo, or emailing us at [email protected].
                ])
            ]),
        ],
        className="page-body",
    )
    layout = html.Div([nav, body, footer], className="site")
    return layout
コード例 #3
0
def Collaborators():
    with open("assets/collaborators/organizations.yml") as f:
        collaborators = yaml.load(f, Loader=yaml.FullLoader)
    num_collaborators = len(collaborators)

    nav = Navbar()
    footer = Footer()

    def get_card(collab):
        return \
            dbc.Col(
                dbc.Card(
                    [
                        dbc.CardHeader(html.H4(collab["name"]),style={"textAlign": "center"}),
                        dbc.CardImg(src='assets/collaborators/photos/%s' % collab['photo'],
                                    top=False,
                                    style={"paddingLeft":   "10px",
                                           "paddingRight":  "10px",
                                           "paddingBottom": collab["padding"],
                                           "paddingTop":    collab["padding"],}),
                        dbc.CardFooter(
                            [
                                html.A(collab["text"],
                                href=collab["website"],
                                className="stretched-link collab-name"),
                            ],
                            className="h-100",
                        )
                    ],
                    style={"borderColor": "#800020"},
                    className="h-100 collab-card"
                ),
                style={"margin": "0 rem"},
            )

    body = dbc.Container([
        dbc.Row([
            dbc.Col([
                html.H2("Our Collaborators"),
                html.
                P('Our models would not have been possible without the valuable data and insights provided \
                                    by our partners. Our aspiration is to develop tools that they can positively affect the \
                                    care they provide to their patients.')
            ])
        ],
                style={'marginBottom': 20}),
        dbc.Row([get_card(collaborators[i])
                 for i in range(num_collaborators)], ),
    ],
                         className="page-body")
    layout = html.Div([nav, body, footer], className="site")
    return layout
コード例 #4
0
def Projections_documentation():
	nav = Navbar()
	footer = Footer()

	body = dbc.Container([
		dbc.Row(
	        [
				dbc.Col([
	            	html.H2("DELPHI Epidemiological Model Documentation"),
	                html.P("""\
	                        This page provides insights on a new epidemiological model developed by this team \
	                        to provide estimates of the number of COVID-19 infections, hospitalizations, and \
	                        deaths in all states of the United States. The model is based on the widely applied \
	                        SEIR (Susceptible-Exposed-Infected-Recovered) modeling approach, which allocates every person to one of four states:
	                       """),
	                dcc.Markdown('''
	                  1. Susceptible: The general population that has not been infected and is not immune.
	                  2. Exposed: People who are currently infected, but are not contagious and lie within the incubation period.
	                  3. Infected: People who are currently infected and are contagious.
	                  4. Recovered: People who recovered and are immune.
	                '''),
	                html.P("""\
	                        Using appropriate case-specific parameters, the SEIR modeling approach can then be applied \
	                        to estimate the dynamics of a pandemic, as people move between these four states over time. \
	                        This base model is then greatly expanded and adjusted for many factors important in the current \
	                        COVID-19 pandemic, including under-detection, hospitalization, and societal counteracting measures. \
	                        The parameter values are based on a meta-analysis of the data in the papers that the group curated.\
	                        Important parameters are varied across different states:
	                      """),
	                # In developing the XYZ model, we have greatly expanded a basic SEIR model and made adjustments for many factors important
	                dcc.Markdown('''
	                  1. Effective contact rate: The effective contact rate measures the number of people that come into contact \
	                  with an infected person per day. This fundamental quantity largely controls the spread of the virus, and \
	                  would be greater in densely populated states (such as NY, CT) and smaller in sparsely populated ones (e.g. AZ, NV).
	                  2. Societal/Governmental Response: This parameter measures, through a parametric nonlinear function, the impact \
	                  of any governmental and societal responses on the spread of the virus over time. This includes such measures as \
	                  government decrees regarding social distancing and sheltering-in-place, as well as increased hygiene-related \
	                  awareness and reduced travel among the general population. This function is calibrated for every state to account \
	                  for the differing responses in different states.
	                '''),
					dcc.Markdown('''Detailed model specifications are available in the following \
	                [technical report](/DELPHI_documentation_pdf). The full source code can be accessed on\
	                [Github](https://github.com/COVIDAnalytics/epidemic-model).'''),
					 ])
			 ],
		 ),
	],
	className="page-body"
	)
	layout = html.Div([nav, body, footer],className="site")
	return layout
コード例 #5
0
def app():

    st.title("Welcome to Cric-Data!")
    st.markdown(
        "Thank you for visiting the webpage. You can find a lot of data analysis as well as data visualization on this page. Please choose your format on the left panel to see your data as well as visualize the data. For a starter click on IPL for a player's IPL profile."
    )

    image = Image.open('./images/consistency.png')
    st.image(
        image,
        caption=
        'Runs vs the normalized standard deviation for all the players in IPL (2008-2020) with a cut off runs 2500. (Number of 30+ scores in the bracket.)'
    )
    Footer()
コード例 #6
0
def Policies():
    nav = Navbar()
    footer = Footer()

    with open('assets/policies/US_Scenarios.json', 'rb') as file:
        projections = json.load(file)

    states = list(projections.keys())
    num_policies = get_num_policies()

    body = dbc.Container(
        [
            dbc.Row(
            [
                dbc.Col(
                [
                    dbc.Jumbotron(
                    [
                        html.H2("Predictions of infections and deaths under a variety of policies"),
                        dcc.Markdown(
                             """Using an extension of our [DELPHI model](/projections), we make predictions \
                             until September 2020 for infections and deaths for all states of the US. \
                             By selecting the state,  the collection of policies imposed and their timing, \
                             the user can compare up to 3 policies simultaneously.
                             """,
                        ),
                        html.Hr(),
                        dcc.Markdown(
                             """The methodology of the model is explained [here](/Policy_evaluation_documentation). \
                             We are currently developing an extension of the model for the world.
                             """,
                        )
                    ],
                    style={'paddingBottom':'0.5rem','paddingTop':'0.8rem'}
                    )
                ]
                ),
            ],
            )
        ] + \
        get_state_num_policy_card(states) + \
        get_policy_cards(num_policies) + \
        get_projections(),
        className="page-body"
    )

    layout = html.Div([nav, body, footer], className="site")
    return layout
コード例 #7
0
def RiskCalc():
    nav = Navbar()
    footer = Footer()
    body = dbc.Container(
        get_lang('language-calc-mortality') +
        get_page_desc('page-desc-mortality') +
        get_labs_indicator('lab_values_indicator') +
        get_feature_cards('features-mortality') +
        get_submit_button('submit-features-calc') +
        get_results_card('score-calculator-card-body', 'calc-input-error') +
        get_inputed_vals('imputed-text-mortality') +
        get_personal_visual('visual-1-mortality') +
        get_model_desc('mortality-model-desc') +
        get_feature_importance('feature-importance-bar-graph'),
        className="page-body")

    layout = html.Div([nav, body, footer], className="site")
    return layout
コード例 #8
0
    def __init__(self, orientation="landscape", filename=None, debug=False):

        self.laterFrames = {
            "portrait": "LaterPage",
            "landscape": "LaterLandscape"
        }
        self.orientation = orientation
        if orientation == "portrait":
            self.refs = [drawFirstPage, drawLaterPage, drawLaterSpecialPage]
            self.frames = [1, 1, 1]
        elif orientation == "landscape":
            self.refs = [
                drawFirstLandscape, drawLaterLandscape,
                drawLaterSpecialLandscape
            ]
            self.frames = [1, 2, 1]
        self.filename = filename
        self.header = Header()
        self.footer = Footer()
        self.debug = debug
        self.doc = None
コード例 #9
0
 def insert_page(self,
                 n,
                 bookmark=None,
                 header=None,
                 footer=None,
                 framestyle="single",
                 content={},
                 pagenumber=None):
     if header is None:
         header = self.header
     if footer is None:
         footer = self.footer
     if header == "empty":
         header = Header()
     if footer == "empty":
         footer = Footer()
     if "top" not in content:
         content.update({"top": EmptyFlowable().as_flowable})
     if "bottom" not in content:
         content.update({"bottom": EmptyFlowable().as_flowable})
     if framestyle == "double":
         if "left" not in content:
             content.update({"left": [EmptyFlowable().as_flowable]})
         if "right" not in content:
             content.update({"right": [EmptyFlowable().as_flowable]})
     if framestyle == "single":
         if "center" not in content:
             content.update({"center": [EmptyFlowable().as_flowable]})
     page = {
         "content": content,
         "header": header,
         "footer": footer,
         "pagenumber": pagenumber,
         "framestyle": framestyle,
         "bookmark": bookmark
     }
     self.insert(n, page)
コード例 #10
0
    def initUI(self):

        in_class = "menu"

        self.sidebar = sidebar.Sidebar(self)
        self.sidebar.window.connect(self.getvalue)

        self.addDockWidget(Qt.LeftDockWidgetArea, self.sidebar)

        header = AppName(in_class)
        footer = Footer()

        add_and_search = AddSearchFrame(in_class)
        add_and_search.add_button.clicked.connect(lambda: self.add_menu(in_class))
        add_and_search.search_button.clicked.connect(
                                        lambda: self.search_menu(add_and_search.search_box))


        self.table = QTableWidget()
        self.table.setColumnCount(5)
        # self.table.setStyleSheet("border: none")
        # self.table.setStyleSheet(
        #     "background-color: rgb(255, 255, 255);\n"
        #     'font: 10pt "MS Shell Dlg 2";\n'
        #     "color: rgb(30, 45, 66);"
        # )

        # self.table.setHorizontalHeaderItem(0, QTableWidgetItem("ID"))
        self.table.setHorizontalHeaderItem(0, QTableWidgetItem("Food"))
        self.table.setHorizontalHeaderItem(1, QTableWidgetItem("Category"))
        self.table.setHorizontalHeaderItem(2, QTableWidgetItem("Price"))
        # self.table.setHorizontalHeaderItem(3, QTableWidgetItem("Bonus"))
        # self.table.setHorizontalHeaderItem(3, QTableWidgetItem("Joining Date"))
        # self.table.setHorizontalHeaderItem(6, QTableWidgetItem("Total Salary"))
        self.table.setHorizontalHeaderItem(3, QTableWidgetItem("Edit"))
        self.table.setHorizontalHeaderItem(4, QTableWidgetItem("Delete"))


        data = self.load_menu_data()
        print(data)

        for x in data:
            print(x)

        self.populate_table(data)
        self.table.resizeColumnsToContents()

        layout = QVBoxLayout()

        layout.addWidget(header)
        layout.addWidget(add_and_search)
        layout.addWidget(self.table)
        # layout.addStretch()
        layout.addWidget(footer)

        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(0)

        centralWidget = QWidget()
        centralWidget.setLayout(layout)

        self.setCentralWidget(centralWidget)
        self.setContentsMargins(0, 0, 0, 0)

        # self.resize(800, 600)
        self.setWindowTitle("Employee")
        self.resize(1160, 605)

        self.show()
        self.center()
コード例 #11
0
    def add_page(self,
                 bookmark=None,
                 header=None,
                 footer=None,
                 framestyle="single",
                 content={},
                 pagenumber=None):
        """
        adds a page to the document, keeping the order

        example "double" framestyle:

        - content = {"left": [figure1, table1], "right": [figure2, table2], "top": [paragraph], "bottom": [table]}

         ____________________________________________________
        | header-left      header-center      header-right   |
        |                                                    |
        |  -----------------------top----------------------  |
        |     ______________              ______________     |
        |    |              |            |              |    |
        |    |     left     |            |     right    |    |
        |    |              |            |              |    |
        |    |______________|            |______________|    |
        |                                                    |
        |  ----------------------bottom--------------------  |
        |                                                    |
        | footer-left       footer-center     footer-right   |
        |______________________________________page-number___|


        example "single" framestyle:

        - content = {"center": [figure, table], "top": [table1], "bottom": [table2]}

         ____________________________________________________
        | header-left      header-center      header-right   |
        |                                                    |
        |  -----------------------top----------------------  |
        |     __________________________________________     |
        |    |                                          |    |
        |    |                   center                 |    |
        |    |                                          |    |
        |    |__________________________________________|    |
        |                                                    |
        |  ----------------------bottom--------------------  |
        |                                                    |
        | footer-left       footer-center     footer-right   |
        |______________________________________page-number___|

        - must-work: a single page switches frame structure from single to double and back

        - frame structure may be infered from content structure, so maybe it is not a parameter???

        - if header/footer must be empty on that page there should be "empty" in

        - pagenumber="right"/"center"/"left" adds a standard number on that page below the footer?

        """
        # most easiest implementation,
        # use deepcopy to make it independent from changes later on
        if header is None:
            header = self.header
        if footer is None:
            footer = self.footer
        if header == "empty":
            header = Header()
        if footer == "empty":
            footer = Footer()
        if "top" not in content:
            content.update({"top": EmptyFlowable().as_flowable})
        if "bottom" not in content:
            content.update({"bottom": EmptyFlowable().as_flowable})
        if framestyle == "double":
            if "left" not in content:
                content.update({"left": [EmptyFlowable().as_flowable]})
            if "right" not in content:
                content.update({"right": [EmptyFlowable().as_flowable]})
        if framestyle == "single":
            if "center" not in content:
                content.update({"center": [EmptyFlowable().as_flowable]})
        page = {
            "content": content,
            "header": header,
            "footer": footer,
            "pagenumber": pagenumber,
            "framestyle": framestyle,
            "bookmark": bookmark
        }
        self.append(page)
コード例 #12
0
def Press():
    with open("assets/press/important_press.yml") as f:
        key_article = yaml.load(f, Loader=yaml.FullLoader)
    num_key_articles = len(key_article)

    with open("assets/press/press.yml") as f:
        article = yaml.load(f, Loader=yaml.FullLoader)
    num_articles = len(article)

    nav = Navbar()
    footer = Footer()

    def build_card(a):
        card_content = \
                [
                    dbc.CardHeader(
                            [
                                html.H6(a['date'],className="press-date") if a['date'] != "ongoing" else None,
                                html.H5(a['title'],className="press-title"),
                                html.H5(a['source'],className="press-source"),
                            ],
                        ),
                    dbc.CardBody(
                        [   dcc.Markdown(a['text']),
                            html.A(
                                href=a['website'],
                                className="stretched-link"
                            ),
                        ],
                    )
                ]

        card = dbc.Card(card_content, className="press-card h-100")

        return dbc.Col(
            [card],
            style={"margin": "0.5rem"},
            xs=12,
            sm=12,
            md=12,
            lg=12,
        )
    articles = \
        [
            dbc.Row(
                [
                    build_card(key_article[i]) for i in range(num_key_articles)
                ],
                justify="around",
            ),
            dbc.Row(dbc.Col(html.Hr())),
            dbc.Row(
                [
                    build_card(article[i]) for i in range(num_articles)
                ],
                justify="around",
            )
        ]

    body = dbc.Container(
            [
                dbc.Row([dbc.Col([html.H2("COVID Analytics in the Press"),])])
            ] + \
            articles,
            className="page-body"
        )

    layout = html.Div([nav, body, footer], className="site")
    return layout
コード例 #13
0
def app():
    st.title("Welcome to ODI-cric-data!")
    st.write('I havenot finished implementing this page yet. Will implement shortly!')
    Footer()
コード例 #14
0
    def initUI(self):

        in_class = "settings"

        self.sidebar = sidebar.Sidebar(self)
        self.sidebar.window.connect(self.getvalue)

        self.addDockWidget(Qt.LeftDockWidgetArea, self.sidebar)

        header = AppName(in_class)
        footer = Footer()

        change_passwordbtn = QPushButton("Change Password")
        change_passwordbtn.setStyleSheet("background-color: rgb(30, 45, 66);\n"
                                         "font: 75 12pt \"MS Shell Dlg 2\";\n"
                                         "color: rgb(255, 255, 255);")
        change_passwordbtn.setFixedWidth(170)
        change_passwordbtn.setFixedHeight(40)
        change_passwordbtn.clicked.connect(self.change_password)

        add_userbtn = QPushButton("Add User")
        add_userbtn.setStyleSheet("background-color: rgb(30, 45, 66);\n"
                                  "font: 75 12pt \"MS Shell Dlg 2\";\n"
                                  "color: rgb(255, 255, 255);")
        add_userbtn.setFixedWidth(170)
        add_userbtn.setFixedHeight(40)
        add_userbtn.clicked.connect(self.add_user)

        edit_restaurant_label = QLabel("Edit Restaurant Information")
        edit_restaurant_label.setStyleSheet(
            "color: rgb(30, 45, 66);\n"
            "font: 75 20pt \"MS Shell Dlg 2\";")

        restaurantlabel = QLabel()
        restaurantlabel.setText("Name")
        restaurantlabel.setGeometry(QRect(80, 100, 47, 13))
        restaurantlabel.setFixedWidth(190)
        restaurantlabel.setFixedHeight(40)
        restaurantlabel.setStyleSheet("color: rgb(30, 45, 66);\n"
                                      'font: 75 18pt "MS Shell Dlg 2";')

        self.restauranttextbox = QLineEdit()
        self.restauranttextbox.setGeometry(QRect(160, 90, 181, 31))
        self.restauranttextbox.setFixedWidth(280)
        self.restauranttextbox.setFixedHeight(40)

        addresslabel = QLabel()
        addresslabel.setText("Job Title")
        addresslabel.setGeometry(QRect(80, 140, 61, 16))
        addresslabel.setFixedWidth(190)
        addresslabel.setFixedHeight(40)
        addresslabel.setStyleSheet("color: rgb(30, 45, 66);\n"
                                   'font: 75 18pt "MS Shell Dlg 2";')

        self.addresstextbox = QLineEdit()
        self.addresstextbox.setGeometry(QRect(160, 130, 181, 31))
        self.addresstextbox.setFixedWidth(280)
        self.addresstextbox.setFixedHeight(40)

        contact = QLabel()
        contact.setText("Salary")
        contact.setGeometry(QRect(80, 180, 47, 13))
        contact.setFixedWidth(190)
        contact.setFixedHeight(40)
        contact.setStyleSheet("color: rgb(30, 45, 66);\n"
                              'font: 75 18pt "MS Shell Dlg 2";')

        self.contacttextbox = QLineEdit()
        self.contacttextbox.setGeometry(QRect(160, 170, 181, 31))
        self.contacttextbox.setFixedWidth(280)
        self.contacttextbox.setFixedHeight(40)
        self.contacttextbox.setValidator(QIntValidator())

        update_btn = QPushButton("Update")
        update_btn.setGeometry(QRect(370, 500, 131, 41))
        update_btn.setStyleSheet("background-color: rgb(30, 45, 66);\n"
                                 "font: 75 12pt \"MS Shell Dlg 2\";\n"
                                 "color: rgb(255, 255, 255);")
        update_btn.setFixedWidth(130)
        update_btn.setFixedHeight(40)
        update_btn.clicked.connect(self.update_data)

        self.load_data()

        hlayout1 = QHBoxLayout()
        hlayout1.addStretch()
        hlayout1.addWidget(change_passwordbtn)
        hlayout1.addWidget(add_userbtn)
        hlayout1.addStretch()

        hlayout2 = QHBoxLayout()
        hlayout2.addStretch()
        hlayout2.addWidget(edit_restaurant_label)
        hlayout2.addStretch()

        hlayout3 = QHBoxLayout()
        hlayout3.addStretch()
        hlayout3.addWidget(restaurantlabel)
        hlayout3.addWidget(self.restauranttextbox)
        hlayout3.addStretch()

        hlayout4 = QHBoxLayout()
        hlayout4.addStretch()
        hlayout4.addWidget(addresslabel)
        hlayout4.addWidget(self.addresstextbox)
        hlayout4.addStretch()

        hlayout5 = QHBoxLayout()
        hlayout5.addStretch()
        hlayout5.addWidget(contact)
        hlayout5.addWidget(self.contacttextbox)
        hlayout5.addStretch()

        hlayout6 = QHBoxLayout()
        hlayout6.addStretch()
        hlayout6.addWidget(update_btn)
        hlayout6.addStretch()

        layout = QVBoxLayout()

        layout.addWidget(header)
        layout.addLayout(hlayout1)
        layout.addStretch()
        layout.addLayout(hlayout2)
        layout.addLayout(hlayout3)
        layout.addLayout(hlayout4)
        layout.addLayout(hlayout5)
        layout.addLayout(hlayout6)
        layout.addStretch()
        layout.addStretch()
        layout.addWidget(footer)

        layout.setContentsMargins(0, 0, 0, 0)

        centralWidget = QWidget()
        centralWidget.setLayout(layout)

        self.setCentralWidget(centralWidget)
        self.setContentsMargins(0, 0, 0, 0)

        self.setWindowTitle("Settings")
        self.resize(1160, 605)

        self.show()
        self.center()
コード例 #15
0
def VentilatorAllocations():

    nav = Navbar()
    footer = Footer()

    models = ["Washington IHME", "COVIDAnalytics"]

    body = dbc.Container(
        [
            dbc.Row(
                [
                    dbc.Jumbotron(
                        [
                            html.H1("Optimization can solve the ventilator shortage"),
                            html.P('''
                                   For severe COVID-19 patients, medical ventilators can spell \
                                   the difference between life and death, but many locations are \
                                   already experiencing shortages.
                                   ''',
                                   className="lead"),
                            html.Hr(),
                            dcc.Markdown('''Fortunately, the dynamics of the \
                                         pandemic differ from one place to another, \
                                         creating opportunities to mitigate shortages by \
                                         dynamically allocating the global ventilator supply.'''),
                        ],
                    ),
                ],
            ),
            dbc.Row(
                [
                    dbc.Col(
                        dbc.Card(
                            [
                                dbc.CardHeader(html.H4("Between hospitals"),
                                               style={"textAlign": "center"}),
                                dbc.CardImg(src="assets/collaborators/photos/Hartford_logo.jpg",
                                            top=False,
                                            style={"paddingLeft":   "10px",
                                                   "paddingRight":  "10px",
                                                   "paddingBottom": "40px",
                                                   "paddingTop":    "40px",}),
                                dbc.CardFooter(
                                    [
                                        html.P("We are working with our partners at Hartford \
                                               HealthCare to ensure that ventilator demand is met \
                                               across hospitals in their network."                                                                                  ),
                                    ],
                                    className="h-100",
                                )
                            ],
                            style={"borderColor": "#800020"},
                            className="h-100"
                        ),
                        xs=12,
                        sm=6,
                        md=6,
                        lg=4,
                        xl=4,
                        style={"padding": "20px"},
                    ),
                    dbc.Col(
                        dbc.Card(
                            [
                                dbc.CardHeader(html.H4("Between states"),
                                               style={"textAlign": "center"}),
                                dbc.CardImg(src="assets/images/allocation.png", top=False),
                                dbc.CardFooter(
                                    [
                                        html.P("We show below how ventilator pooling \
                                               across \
                                               states can solve the US shortage, even without \
                                               federal intervention."                                                                     ),
                                    ],
                                    className="h-100",
                                ),
                            ],
                            style={"borderColor": "#800020"},
                            className="h-100",
                        ),
                        xs=12,
                        sm=6,
                        md=6,
                        lg=4,
                        xl=4,
                        style={"padding": "20px"},
                    ),
                    dbc.Col(
                        dbc.Card(
                            [
                                dbc.CardHeader(html.H4("Between countries"),
                                               style={"textAlign": "center"}),
                                dbc.CardImg(src="assets/images/world-map.png", top=False,
                                            style={"paddingLeft":   "10px",
                                                   "paddingRight":  "10px",
                                                   "paddingBottom": "20px",
                                                   "paddingTop":    "20px",}),
                                dbc.CardFooter(
                                    [
                                        html.P("We hope our optimization model will provide a \
                                               blueprint for international collaboration on \
                                               ventilator inventory management."                                                                                )
                                    ],
                                    className="h-100",
                                )
                            ],
                            style={"borderColor": "#800020"},
                            className="h-100",
                        ),
                        xs=12,
                        sm=6,
                        md=6,
                        lg=4,
                        xl=4,
                        style={"padding": "20px"},
                    ),
                ],
                justify="around",
            ),
            dbc.Row(
                [
                    html.Iframe(src="https://www.youtube.com/embed/SwiOFEZc0Gs",
                                width="711",
                                height="400"),
                ],
                justify="around",
                style={"paddingBottom": "20px"},
            ),
            dbc.Row(
                [
                    dbc.Col(
                        [
                            dcc.Markdown('''Interested in more details? Check out this \
                                         [technical report](/ventilator_documentation_pdf), \
                                         or take a look at our [code]\
                                         (https://github.com/COVIDAnalytics/ventilator-allocation)!
                                         '''),
                        ],
                    ),
                ],
            ),
            dbc.Row(
            [
                dbc.Jumbotron(
                [
                    html.H2("Why share ventilators between states?"),
                    html.P('''As highlighted in the visuals below, the number of ventilators \
                              available across all 50 states - without even accounting for the \
                              federal stockpile - exceeds national demand.''',
                           className="lead"),
                    html.Hr(),
                    dcc.Markdown('''Yet with the current \
                                 allocation of ventilators, some states are expected to face strong \
                                 shortages over time. And this is true for different pandemic \
                                 projection models, including our own [DELPHI](/projections) \
                                 forecasts and those from the [University of Washington’s IHME model]\
                                 (https://covid19.healthdata.org/united-states-of-america).
                                 '''),
                ]
                ),
            ],
            )
        ] + \
        [
            dbc.Row(
            [
                dbc.Col(
                [
                    html.H6('Select the Data Source:',id="date-projections"),
                    html.Div(
                        dcc.Dropdown(
                            id = 'base-model-dropdown',
                            options = [{'label': x, 'value': x} for x in models],
                            value = 'COVIDAnalytics',
                        ),
                    ),
                ],
                ),
            ]
            )
        ] + \
            get_shortage() + \
        [
            dbc.Row(
                [
                    dbc.Jumbotron(
                    [
                        html.H2("How can states share ventilators optimally?"),
                        dcc.Markdown('''
                            We know how many ventilators are in each state from public data, and we \
                            estimate that up to 450 ventilators per day could be made available \
                            through a federal surge \
                            (see [documentation](/ventilator_documentation_pdf) for details). \
                            Our optimization model recommends surge supply allocations and interstate transfers to reduce ventilator shortage as quickly and efficiently as possible.'''),
                        html.Hr(),
                        html.P('Use the interactive tool below to experiment with different reallocation policies.', className="lead"),
                    ]
                    ),
                ],
            )
        ] + \
            get_transfers_visuals() + \
            get_transfers_table() + \
        [
            dbc.Row([
           dbc.Col(
            html.Div(
             html.A(
              "Download the Ventilator Shortage Data",
              id="download-link-demand",
             ),
             style={'textAlign':"center"}
            )
           ),
           dbc.Col(
            html.Div(
             html.A(
              "Download the Ventilator Transfers Data",
              id="download-link-tranfers",
             ),
             style={'textAlign':"center"}
            )
           ),
          ]
            ),
        ],
       className="page-body"
    )

    layout = html.Div([nav, body, footer], className="site")
    return layout
コード例 #16
0
def InteractiveGraph():
    nav = Navbar()
    footer = Footer()

    categories = ["Comorbidities", "Symptoms", "Treatment", "Lab Test Results"]

    demographics = ["Median Age", "% Male"]
    df = pd.read_csv('data/clinical_outcomes_database.csv')
    survivor_options = df.Survivors.unique()
    data_csv_string = df.to_csv(index=False, encoding='utf-8')
    data_csv_string = "data:text/csv;charset=utf-8," + urllib.parse.quote(
        data_csv_string)
    del df
    survivor_options = [x for x in survivor_options if str(x) != 'nan']

    body = dbc.Container(
        [
            dbc.Row([
                dbc.Col([html.H2("Insights")]),
            ], ),
            dbc.Row([
                dbc.Col([
                    html.Div([
                        dcc.Markdown(
                            """\
                                Effective decision making needs data. \
                                We interactively visualize a new [dataset](/dataset) \
                                that aggregates data from over 100 published clinical \
                                studies and preprints released between December 2019 \
                                and March 2020 on COVID-19. We hope that by summarizing\
                                the results of multiple studies, we can get a clearer \
                                picture on the virus.
                             """, ),
                        html.P(
                            """\
                                Below you will find a series of \
                                options to create descriptive graphs relating to patient \
                                demographic characteristics, symptoms, treatments, \
                                comorbidities, lab results, and outcomes. \
                                Each data point corresponds to a different study that \
                                comprises multiple patients. We hope that you can easily \
                                derive your own insights and discover the interesting \
                                implications of the disease.
                             """, )
                    ])
                ]),
            ], ),
            dbc.Row([
                dbc.Col(
                    [
                        html.H5('What would you like to compare?'),
                        html.Div(
                            dcc.Dropdown(id='categories_dropdown',
                                         options=[{
                                             'label': x,
                                             'value': x
                                         } for x in categories],
                                         value='Comorbidities',
                                         style={'marginBottom': 10}), ),
                        html.Div(id='display-selected-values', ),
                        html.Div([
                            html.Div(
                                dcc.Dropdown(id='y_axis_dropdown',
                                             value='Hypertension',
                                             optionHeight=50,
                                             style={
                                                 'marginBottom': 10,
                                                 'marginTop': 10
                                             }), )
                        ]),
                        html.P('Select the Demographic (Horizontal Axis)'),
                        html.Div(
                            dcc.Dropdown(id='x_axis_dropdown',
                                         options=[{
                                             'label': x,
                                             'value': x
                                         } for x in demographics],
                                         value='% Male',
                                         style={
                                             'marginBottom': 10,
                                             'marginTop': -5
                                         }), ),
                        html.P('Select the Population Type:'),
                        html.Div(
                            dcc.Checklist(
                                id='survivors',
                                options=[{
                                    'label': x,
                                    'value': x
                                } for x in survivor_options],
                                value=['Non-survivors only', 'Survivors only'],
                                labelStyle={'color': 'black'},
                                style={
                                    'width': '50%',
                                    'marginTop': -5
                                })),
                    ],
                    width="True",
                ),
            ],
                    justify="center"),
            dbc.Row([
                dbc.Col([
                    html.Div(
                        id='interactive_graph',
                        children=[],
                    ),
                ]),
            ]),
            dbc.Row([
                dbc.Col(
                    html.Div(html.A(
                        "Download the Data",
                        id="download-link",
                        download="covid_analytics_clinical_data.csv",
                        href=data_csv_string,
                        target="_blank"),
                             style={'textAlign': "center"})),
            ]),
        ],
        className="page-body",
    )

    layout = html.Div([nav, body, footer], className="site")
    return layout
コード例 #17
0
def Homepage():

    nav = Navbar()
    footer = Footer()

    def build_tom_us_map():
        tomorrow = datetime.date.today() + datetime.timedelta(days=1)
        return build_continent_map(tomorrow)

    def build_card(imgTop, titles, text, img, links):
        cardbody = []
        for i, t in enumerate(titles):
            cardbody.append(html.A(t, href=links[i], className="card-title"))
            cardbody.append(dcc.Markdown(text[i]))

        if imgTop:
            card_content = \
                    [
                        dbc.CardImg(src=img, top=False),
                        dbc.CardBody(
                            cardbody,
                            className="home-card-body"
                        ),
                    ]

        else:
            card_content = \
                    [
                        dbc.CardBody(
                            cardbody,
                            className="home-card-body"
                        ),
                        dbc.CardImg(src=img, top=True),
                    ]

        card = dbc.Card(card_content, className="home-card h-100")

        return dbc.Col(
            [card],
            style={"margin": "0.5rem"},
        )

    data_text = '''
           130+ international Covid-19 clinical studies,
           aggregated into a single dataset.
           '''
    insights_text = '''
        Key characteristics of COVID-19 patients in an
        interactive summary. '''

    projections_text = '''
        Epidemiological predictions of COVID-19 \
        infections, hospital stays, and mortalities.
        '''

    policy_text = '''
        Predicting infections and deaths based on various policy \
        implementations'''

    ventilator_text = '''
           Leveraging delays between state peaks to \
           optimally re-use ventilators.
           '''

    mortality_calculator_text = '''
          Personalized calculator predicting mortality upon hospitalization.
          '''

    infection_calculator_text = '''
        Personalized calculator predicting results of COVID test.
        '''

    financial_text = '''
        Unemployment is rising. How analytics can help inform COVID-19 related financial decisions.
        '''

    cards = \
        [
            {
                "titles": ["Data","Insights"],
                "text": [data_text,insights_text],
                "image": "assets/images/insights-4.png",
                "links": ["/dataset","/interactive-graph"]
            },
            {
                "titles": ["Infection risk calculator","Mortality risk calculator"],
                "text": [infection_calculator_text,mortality_calculator_text],
                "image": "assets/images/infection_logo.jpg",
                "links": ["/infection_calculator","/mortality_calculator"]
            },
            {
                "titles": ["Case predictions","Policy evaluations"],
                "text": [projections_text,policy_text],
                "image": "assets/images/forecast-1.png",
                "links": ["/projections","/policies"]
            },
            {
                "titles": ["Ventilator allocation"],
                "text": [ventilator_text],
                "image": "assets/images/allocation.png",
                "links": ["/ventilator_allocation"]
            },
            {
                "titles": ["Financial relief planning"],
                "text": [financial_text],
                "image": "assets/images/financial_logo.jpeg",
                "links": ["/financial_relief","/interactive-graph"]
            }

        ]

    body = dbc.Container([
        dbc.Row(
            dbc.Col(
                dcc.Markdown('''
                         We are a group of researchers from the [MIT](http://mit.edu/) [Operations Research Center](https://orc.mit.edu/), \
                         led by Professor [Dimitris Bertsimas](https://www.mit.edu/~dbertsim/). \
                         We aim to quickly develop and deliver tools for hospitals and policymakers in the US to combat the spread of COVID-19. \
                         This work represents a collaborative effort with [multiple hospitals](/collaborators) which have been providing us with \
                         data and support throughout the model creation process.
                         '''), ), ),
        dbc.Row(
            [
                build_card(False, cards[0]["titles"], cards[0]["text"],
                           cards[0]["image"], cards[0]["links"]),
                build_card(True, cards[1]["titles"], cards[1]["text"],
                           cards[1]["image"], cards[1]["links"]),
                build_card(False, cards[2]["titles"], cards[2]["text"],
                           cards[2]["image"], cards[2]["links"]),
                build_card(True, cards[3]["titles"], cards[3]["text"],
                           cards[3]["image"], cards[3]["links"]),
                build_card(False, cards[4]["titles"], cards[4]["text"],
                           cards[4]["image"], cards[4]["links"]),
            ],
            justify="around",
            no_gutters=True,
        ),
        dbc.Row([
            dbc.Col([
                html.Div(
                    id='us_map_homepage',
                    children=build_tom_us_map(),
                ),
                html.P(
                    children=get_world_map_text(),
                    style={'color': 'gray'},
                ),
            ])
        ], )
    ],
                         className="page-body")

    layout = html.Div([nav, body, footer], className="site")
    return layout
コード例 #18
0
def ProjectState():
    nav = Navbar()
    footer = Footer()

    body = dbc.Container(
        [
           dbc.Row(
            [
                dbc.Col(
                [
                    html.H2("DELPHI Epidemiological Case Predictions"),
                    dcc.Markdown("""\
                            A critical tool for COVID-19 planning is charting out the progression \
                            of the pandemic across the United States and the world. \
                            We've developed a new epidemiological model called DELPHI, which \
                            forecasts infections, hospitalizations, and deaths. \
                            You can think of our model as a standard \
                            [SEIR model](https://en.wikipedia.org/wiki/Compartmental_models_in_epidemiology#The_SEIR_model) \
                            with additional \
                            features specific to the COVID-19 pandemic, like under-detection and \
                            differentiated government intervention.
                           """),
                    dcc.Markdown('''If you want to learn more, check out the \
                                 [documentation](/projections_documentation) or \
                                 [source code](https://github.com/COVIDAnalytics/epidemic-model).'''),
                    dcc.Markdown('''**Note: The model has been updated on 7/4/2020 to better reflect the resurgence of \
                                 cases in various locations. The projections could differ significantly from previous results in certain areas.** '''),
                    dbc.Card(
                        [
                            dbc.CardBody(
                                [
                                html.H5("Note: what do we mean by \"active cases\"?"),
                                dcc.Markdown("We define a COVID-19 case as **active** \
                                             if it has not yet resulted in recovery \
                                             or death. You may notice a discrepancy \
                                             between the number of active cases here \
                                             and on the \
                                             [JHU map](https://coronavirus.jhu.edu/map.html). \
                                             The JHU map is very good at keeping track of new cases, \
                                             but does not always publish data on recovered cases, \
                                             which can lead to overestimating currently active \
                                             cases."),
                                dcc.Markdown("**Disclaimer:** Our total counts only account for \
                                             countries in which we have sufficient data and where \
                                             the pandemic is currently active. In particular, it \
                                             excludes some East Asian countries where the pandemic \
                                             has largely passed.\n \
                                             \nCountry-level projections are modelled based on all \
                                             historical data to increase the accuracy of future \
                                             predictions. As such, daily counts extracted from \
                                             the model may not exactly correspond with reports."),
                                ]
                            ),
                        ],
                        className='projections-general-card'
                    ),
                ]
                ),
            ],
            )
        ] + \
            get_top_visual() + \
            get_bottom_visual(),
       className="page-body"
    )

    layout = html.Div([nav, body, footer],className="site")
    return layout
コード例 #19
0
    def initUI(self):

        in_class = "orders"

        self.sidebar = sidebar.Sidebar(self)
        self.sidebar.window.connect(self.getvalue)

        self.addDockWidget(Qt.LeftDockWidgetArea, self.sidebar)

        header = AppName(in_class)
        footer = Footer()

        self.scrollArea = QScrollArea()
        # self.scrollArea.setContentsMargins(0, 0, 0, 0)
        self.scrollArea.setStyleSheet("Border: none")

        left_content = QVBoxLayout(self.scrollArea)
        left_content.setContentsMargins(0, 0, 0, 0)
        left_content.setSpacing(0)

        table = QLabel("Table No")

        table_list = self.get_tables()

        self.table_no = QComboBox()
        self.table_no.setFixedWidth(250)
        self.table_no.addItems(table_list)

        hl = QHBoxLayout()
        hl.addStretch()
        hl.addWidget(table)
        hl.addStretch()
        hl.addWidget(self.table_no)
        hl.addStretch()

        # left_content.addLayout(hlayout1)
        left_content.addLayout(hl)

        menu_list = self.get_menu_items()

        for key, value in menu_list.items():
            if value:
                category = QLabel(key)
                category.setAlignment(Qt.AlignCenter)

                left_content.addWidget(category)

                for x in value:
                    quantity = QLineEdit()
                    quantity.setFixedWidth(50)
                    quantity.setFixedHeight(50)

                    xtimes = QLabel(" X ")

                    widget2 = MenuItems(x)
                    widget2.setMouseTracking(True)
                    widget2.mouseMoveEvent = functools.partial(self.mouse_moved, source_object=widget2)
                    widget2.leaveEvent = functools.partial(self.mouse_left, source_object=widget2)
                    widget2.mousePressEvent = functools.partial(self.mouse_pressed,
                                                                source_object=[quantity, widget2])
                    widget2.setStyleSheet("background-color: grey; color: black")

                    hlayout2 = QHBoxLayout()
                    hlayout2.setContentsMargins(10, 10, 0, 0)
                    hlayout2.addWidget(quantity)
                    hlayout2.addWidget(xtimes)
                    hlayout2.addWidget(widget2)

                    # widget2.mousePressEvent = functools.partial(self.mouse_pressed, source_object=hlayout2)

                    left_content.addLayout(hlayout2)
                    left_content.addStretch()

        # left_content.addLayout(hlayout2)



        # self.thumbnail = QHBoxLayout()
        # self.scrollArea.setMaximumWidth(self.width()/2)

        self.scrollChildArea = QWidget()
        self.scrollChildArea.setLayout(left_content)

        self.scrollArea.setWidgetResizable(True)
        self.scrollArea.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.scrollArea.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
        # self.scrollArea.setMinimumHeight(160)
        # self.scrollArea.setMaximumHeight(160)
        self.scrollArea.setWidget(self.scrollChildArea)
        # self.scrollArea.setFrameShape(QFrame().NoFrame)
        self.scrollArea.setStatusTip("Preview")

        # ---------------------------------------------------
        self.scrollArea2 = QScrollArea()
        # self.scrollArea2.setContentsMargins(0, 0, 0, 0)
        self.scrollArea2.setStyleSheet("Border: none")
        # ---------------------------------------------------

        self.right_content = QVBoxLayout(self.scrollArea2)
        self.right_content.setContentsMargins(0, 0, 0, 0)
        # self.right_content.setAlignment(Qt.AlignCenter)

        # ---------------------------------------------------
        self.scrollChildArea2 = QWidget()
        self.scrollChildArea2.setLayout(self.right_content)

        self.scrollArea2.setWidgetResizable(True)
        self.scrollArea2.setHorizontalScrollBarPolicy(Qt.ScrollBarAlwaysOff)
        self.scrollArea2.setVerticalScrollBarPolicy(Qt.ScrollBarAlwaysOn)
        # self.scrollArea2.setMinimumHeight(160)
        # self.scrollArea2.setMaximumHeight(160)
        self.scrollArea2.setWidget(self.scrollChildArea2)
        # self.scrollArea2.setFrameShape(QFrame().NoFrame)
        self.scrollArea2.setStatusTip("Preview")
        bar = self.scrollArea2.verticalScrollBar()
        bar.rangeChanged.connect(lambda: bar.setValue(bar.maximum()))
        # ---------------------------------------------------

        bill = QLabel()
        bill.setText("Bill")
        bill.setAlignment(Qt.AlignCenter)
        bill.setFixedWidth(450)
        bill.setStyleSheet("font: 75 20pt \"MS Shell Dlg 2\";")

        self.msg = QLabel("")
        self.msg.setFixedHeight(50)

        print_bill = QPushButton("Send")
        print_bill.setFixedWidth(100)
        print_bill.setFixedHeight(50)
        print_bill.setStyleSheet("font: 75 12pt \"MS Shell Dlg 2\";\n"
                                 "background-color: rgb(30, 45, 66);\n"
                                 "color: rgb(255, 255, 255);")
        print_bill.clicked.connect(self.send_bill)

        hl2 = QHBoxLayout()
        hl2.addWidget(self.msg, alignment=Qt.AlignCenter)
        hl2.addWidget(print_bill, alignment=Qt.AlignRight)

        self.total = 0.00
        self.food_order = []

        self.total_amount = QLabel("Total : " + str(self.total))
        self.total_amount.setAlignment(Qt.AlignRight)


        self.right_content.addWidget(bill)
        self.right_content.addStretch()
        self.right_content.addWidget(self.total_amount)
        self.right_content.addLayout(hl2)
        self.right_content.addStretch()

        content = QGridLayout()
        content.setContentsMargins(0, 0, 0, 0)
        content.setSpacing(0)

        content.addWidget(self.scrollArea, 0, 0)
        content.addWidget(self.scrollArea2, 0, 1)


        layout = QVBoxLayout()

        layout.addWidget(header)
        layout.addLayout(content)
        layout.addStretch()
        layout.addWidget(footer)

        layout.setContentsMargins(0, 0, 0, 0)

        centralWidget = QWidget()
        centralWidget.setLayout(layout)

        self.setCentralWidget(centralWidget)
        self.setContentsMargins(0, 0, 0, 0)



        self.setWindowTitle("Settings")
        self.resize(1160, 605)

        self.show()
        self.center()
コード例 #20
0
def Dataset():
	nav = Navbar()
	footer = Footer()

	dataset = "data/clinical_outcomes_database.csv"
	demographics = ["Median Age", "% Male"]
	df = pd.read_csv(dataset)

	data_csv_string = df.to_csv(index=False, encoding='utf-8')
	data_csv_string = "data:text/csv;charset=utf-8," + urllib.parse.quote(data_csv_string)

	ref_data = "data/reference_ranges.csv"
	ref = pd.read_csv(ref_data)
	ref_data_csv_string = ref.to_csv(index=False, encoding='utf-8')
	ref_data_csv_string = "data:text/csv;charset=utf-8," + urllib.parse.quote(ref_data_csv_string)

	df = df.loc[:,get_data_cols()]
	df = df.head(50)

	table = dash_table.DataTable(
				id="data-table",
			    data=df.to_dict('records'),
			    columns=[{'id': c, 'name': c} for c in df.columns],
				style_data={
			        'whiteSpace': 'normal',
			        'height': 'auto',
			    },
				style_table={
					'overflowX': 'auto',
					'maxHeight': '400px',
					'overflowY': 'auto',
					'border': 'thin lightgrey solid',
				},
				style_cell={
			        'height': 'auto',
			        'minWidth': '0px',
					'width': '180px',
					'maxWidth': '180px',
			        'whiteSpace': 'normal',
					'textAlign': 'center',
					'font_size': '14px',
					'font-family': 'arial',
			    },
				style_data_conditional=[
			        {
			            'if': {'row_index': 'odd'},
			            'backgroundColor': 'rgb(248, 248, 248)'
			        }
			    ],
			    style_header={
			        'backgroundColor': 'rgb(230, 230, 230)',
			        'fontWeight': 'bold'
			    },
				fixed_rows={ 'headers': True, 'data': 0 },
			)

	body = dbc.Container([
		dbc.Row(
	        [
				dbc.Col([
	            	html.H2("Dataset"),
	                html.P('As policy makers and healthcare professionals tackle the COVID-19 pandemic, \
	                	a critical factor inhibiting effective decision making at regional, national, \
	                	and global levels is a lack of relevant data on patient outcomes. We hope to partially \
	                	alleviate this problem by sharing the following dataset, which aggregates data from over \
	                	160 published clinical studies and preprints released between December 2019 and April 2020.'),
					html.P('We would like to remind the reader that the raw data in this dataset should not \
					 be used to estimate trends in the general population such as mortality rates. \
					 Indeed, this dataset is largely derived from studies run in hospitals and nations\
					 affected with COVID-19 generally only admit seriously affected patients to \
					 hospitals. However, it should be possible to derive reasonably accurate estimates\
					 of these quantities by (a) accounting for the prevalence of asymptomatic \
					 patients, and (b) including only sufficiently representative studies. \
					 So far, the majority of the included studies are using patient data from China.\
					 We will keep on updating this resource as more research investigations from \
					 other countries are getting published.'),
					html.H5("Guidance for Use of the Dataset"),
					html.P('At a high level, each row of the dataset represents a cohort of patients.\
					 Some papers study a single cohort, while others study several cohorts, \
					 and still others report results about one cohort and one or more subcohorts;\
					 Each of these cohorts are included as rows in the dataset. \
					 The in-browser dataset is a subset of the recorded features and studies. For the full dataset, please \
					 download the data.'
					 ),
					dcc.Markdown('''Detailed information regarding the use of this resource is available [here](/dataset_documentation).'''),
					 ])
			 ]
		 ),
	    dbc.Row([
				dbc.Col(
					html.Div(
						html.A(
							"Download the Data",
							id="download-link",
							download="covid_analytics_clinical_data.csv",
							href=data_csv_string,
		        			target="_blank"						),
						style={'textAlign':"center"}
					)
				),
				dbc.Col(
					html.Div(
						html.A(
							"Download the Reference for Lab Values",
							id="download-reference-link",
							download="covid_analytics_reference_ranges.csv",
							href=ref_data_csv_string,
		        			target="_blank"						),
						style={'textAlign':"center"}
					)
				),
				]
		),
	  dbc.Row(
	           [
	              dbc.Col(
	                [
	                   dbc.Col([table,]) ,
	                ],
					width=12
	             ),
	            ],
	        ),

	],
	className="page-body"
	)
	layout = html.Div([nav, body, footer],className="site")
	return layout
コード例 #21
0
def FinancialReliefPlanning():
    nav = Navbar()
    footer = Footer()

    body = dbc.Container(
            [
                dbc.Row(
                [
                    dbc.Col(
                    [
                        dbc.Jumbotron(
                        [
                            html.H2("Analytics-Driven Financial Relief Planning"),
                            dcc.Markdown(
                                 """The unemployment rate in the US has reached levels not seen since the Great Depression
                                    as millions of workers are out of work and trying to navigate difficult financial decisions.
                                    Households are struggling to figure out revised budgets, estimated cuts in spending, and
                                    potential resources to access additional funds. The decisions are complicated because
                                    there is an overwhelming number of COVID related benefits to understand, for example, the
                                    recent [CARES Act](https://home.treasury.gov/policy-issues/cares) and the
                                    [IRS Tax relief benefits](https://www.irs.gov/newsroom/coronavirus-related-relief-for-retirement-plans-and-iras-questions-and-answers).
                                 """,
                            ),
                            html.Hr(),
                            dcc.Markdown(
                                 """Although it is now easier to tap into retirement funds for short term budgeting needs,
                                    households need to evaluate overall tax consequences and long-term retirement plan goals
                                    to make the best decisions. It is very complicated to sort through all the information and
                                    options available. Analytics can help structure the information, define short and long-term
                                    household objectives, as well as incorporate personal constraints. Optimization techniques
                                    can be used to evaluate all possible decisions and determine the specific actions the
                                    household can take to navigate the current crisis and stay the course toward their future
                                    goals.
                                 """,
                            )
                        ],
                        style={'paddingBottom':'0.5rem','paddingTop':'0.8rem'}
                        )
                    ]
                    ),
                ],
                )
            ] + \
            [
                dbc.Row(
                [
                    dbc.Col(
                    [
                        dbc.Jumbotron(
                        [
                            html.H2("Financial Relief Planning Tool"),
                            dcc.Markdown(
                                 """A team of MIT PhDs from the Operations Research Center with 20+ years of experience in finance,
                                    analytics, and robust optimization have created the COVID Relief Planning Assistant to help those
                                    impacted create a short-term financial plan. This online tool leverages advanced analytics and
                                    modeling to tell households what to do next and why. There is no cost to access the tool
                                    which provides actionable financial guidance, personalized for each household impacted by
                                    reduced or lost income. The methodology of the tool is explained [here](https://www.savvifi.com/files/COVID_Relief_Planning.pdf).
                                 """,
                            ),
                            html.Hr(),
                            html.H5("COVID Relief Planning Assistant", style={"color":"#800020"}),
                            dcc.Markdown(
                                 """Click [here](https://covid.savvifi.com/) to get started on your short-term financial plan.
                                 """,
                            ),
                            html.H5("COVID Educational Resources"),
                            dcc.Markdown(
                                 """Click [here](https://help.savvifi.com/en/collections/2289225-covid-19-educational-resources)
                                    to find additional educational content for those affected by the COVID-19 crisis.
                                 """,
                            )
                        ],
                        style={'paddingBottom':'0.5rem','paddingTop':'0.8rem'}
                        )
                    ]
                    ),
                ],
                )
            ],
            className="page-body"
        )

    layout = html.Div([nav, body, footer], className="site")
    return layout
コード例 #22
0
def app():
    st.title("Welcome to T20I-cric-data!")
    st.sidebar.title('Find Player Profile')
    user_input_player = st.sidebar.text_input(
        label="Enter Cricketer's Name Eg. (DA Warner)")
    #user_input_player = st.sidebar.text_input(label="Enter Cricketer's Name Eg. (DA Warner)")
    get_top_players = st.sidebar.checkbox(label="Get Top Players in the T20Is",
                                          value=False)

    if (not user_input_player) or (not get_top_players):
        st.write(
            "You can try putting a cricket player's name in the left panel to see his profile as well as visualise the data."
        )

    if user_input_player:
        player_name = find_name(user_input_player, t20=True)

        if player_name is None:
            st.markdown('**' + user_input_player + '** ' + " is not found.")
        else:
            bat_bowl = st.sidebar.selectbox(label="Batting/Bowling Profile",
                                            options=("bat", "bowl"))

            bat = True
            xaxis = 'season'
            yaxis = 'Runs'
            if bat_bowl == 'bowl':
                bat = False
                yaxis = 'Wickets'

            year_from = st.sidebar.number_input("Year from",
                                                min_value=2005,
                                                max_value=2021,
                                                value=2005,
                                                step=1)
            year_to = st.sidebar.number_input("Year to",
                                              min_value=2005,
                                              max_value=2021,
                                              value=2021,
                                              step=1)
            visualize = st.sidebar.checkbox(label="Visualize", value=False)

            st.markdown('**' + player_name + '**')
            df = get_player_profile(player_name,
                                    batsman=bat,
                                    year_from=year_from,
                                    year_to=year_to,
                                    t20=True)
            st.table(df)

            if visualize:
                numeric_cols = list(
                    df.select_dtypes(include=np.number).columns.values)
                xaxis = st.sidebar.selectbox(label="x-axis",
                                             options=numeric_cols)
                yaxis = st.sidebar.selectbox(label="y-axis",
                                             options=numeric_cols,
                                             index=numeric_cols.index(yaxis))

                fig = px.bar(df, x=xaxis,
                             y=yaxis)  #, range_x=[year_from, year_to])
                st.plotly_chart(fig)

    elif get_top_players:
        top_N = st.sidebar.number_input("Show Top ",
                                        max_value=25,
                                        value=10,
                                        step=1)
        cols = [
            'Runs', 'Innings', 'NO', 'BF', 'HS', 'Ave', 'SR', '50s', '100s',
            '4s', '6s'
        ]
        sort_by = st.sidebar.selectbox(label="Sort By", options=cols)
        df_top = top_players(sort_by=sort_by, topN=top_N)
        st.markdown('**' + 'Top T20I batsmen sorted by ' + sort_by + '**' +
                    ' (Cut Off Runs =1000)')
        st.table(df_top)

    #st.sidebar.title('Team Profile')
    #all_ipl_teams=("Chennai Super Kings", "Delhi Capitals", "Punjab Kings", "Kolkata Knight Riders",
    #        "Mumbai Indians", "Rajasthan Royals", "Royal Challengers Bangalore", "Sunrisers Hyderabad")
    #team_name = st.sidebar.selectbox(label="Team name",
    #                                options=all_ipl_teams)
    Footer()
コード例 #23
0
    def initUI(self):

        # sidebar = Sidebar(self)
        # self.addDockWidget(Qt.LeftDockWidgetArea, sidebar)

        header = AppName("login")
        footer = Footer()

        layout = QVBoxLayout()

        username_row = QHBoxLayout()
        password_row = QHBoxLayout()
        login_btn = QHBoxLayout()
        errorMsg = QHBoxLayout()

        self.labelUsername = QLabel("Username")
        self.usernameInput = QLineEdit()
        self.usernameInput.setFixedWidth(300)

        self.labelPassword = QLabel("Password")
        self.passwordInput = QLineEdit()
        self.passwordInput.setEchoMode(QLineEdit.Password)

        self.passwordInput.setFixedWidth(300)

        self.loginBtn = QPushButton("Login")
        self.loginBtn.setFixedWidth(200)
        self.loginBtn.setFocusPolicy(Qt.StrongFocus)
        self.loginBtn.setShortcut("Return")
        self.loginBtn.clicked.connect(self.loginBtnClicked)

        self.loginErrorMsg = QLabel("")

        username_row.addStretch()
        username_row.addWidget(self.labelUsername)
        username_row.addWidget(self.usernameInput)
        username_row.addStretch()

        password_row.addStretch()
        password_row.addWidget(self.labelPassword)
        password_row.addWidget(self.passwordInput)
        password_row.addStretch()

        login_btn.addStretch()
        login_btn.addWidget(self.loginBtn)
        login_btn.addStretch()

        errorMsg.addStretch()
        errorMsg.addWidget(self.loginErrorMsg)
        errorMsg.addStretch()

        layout.addWidget(header)
        # layout.addWidget(frame)
        layout.addStretch()
        layout.addLayout(username_row)
        layout.addLayout(password_row)
        layout.addLayout(login_btn)
        layout.addLayout(errorMsg)
        layout.addStretch()
        layout.addWidget(footer)

        layout.setContentsMargins(0, 0, 0, 0)

        centralWidget = QWidget()
        centralWidget.setLayout(layout)

        self.setCentralWidget(centralWidget)
        self.setContentsMargins(0, 0, 0, 0)

        self.resize(800, 600)
        self.setWindowTitle("Login")
        self.show()

        self.center()
コード例 #24
0
def app():
    st.title("Welcome to IPL-cric-data!")
    st.sidebar.title('Find Player Profile')
    user_input_player = st.sidebar.text_input(
        label="Enter Cricketer's Name Eg. (Tendulkar)"
    )  #, value="SR Tendulkar")

    if not user_input_player:
        st.write(
            "You can try putting a cricket player's name in the left panel to see his profile as well as visualise the data."
        )

    if user_input_player:
        player_name = find_name(user_input_player, ipl=True)
        #player_name = user_input_player

        if player_name is None:
            st.markdown('**' + user_input_player + '** ' + " is not found.")
        else:
            bat_bowl = st.sidebar.selectbox(label="Batting/Bowling Profile",
                                            options=("bat", "bowl"))

            bat = True
            xaxis = 'season'
            yaxis = 'Runs'
            if bat_bowl == 'bowl':
                bat = False
                yaxis = 'Wickets'

            year_from = st.sidebar.number_input("Year from",
                                                min_value=2008,
                                                max_value=2021,
                                                value=2008,
                                                step=1)
            year_to = st.sidebar.number_input("Year to",
                                              min_value=2008,
                                              max_value=2021,
                                              value=2021,
                                              step=1)
            visualize = st.sidebar.checkbox(label="Visualize", value=False)

            st.markdown('**' + player_name + '**')
            df = get_player_profile(player_name,
                                    batsman=bat,
                                    year_from=year_from,
                                    year_to=year_to,
                                    ipl=True)
            st.table(df)

            if visualize:
                numeric_cols = list(
                    df.select_dtypes(include=np.number).columns.values)
                xaxis = st.sidebar.selectbox(label="x-axis",
                                             options=numeric_cols)
                yaxis = st.sidebar.selectbox(label="y-axis",
                                             options=numeric_cols,
                                             index=numeric_cols.index(yaxis))

                fig = px.bar(df, x=xaxis,
                             y=yaxis)  #, range_x=[year_from, year_to])
                st.plotly_chart(fig)

    #st.sidebar.title('Team Profile')
    #all_ipl_teams=("Chennai Super Kings", "Delhi Capitals", "Punjab Kings", "Kolkata Knight Riders",
    #        "Mumbai Indians", "Rajasthan Royals", "Royal Challengers Bangalore", "Sunrisers Hyderabad")
    #team_name = st.sidebar.selectbox(label="Team name",
    #                                options=all_ipl_teams)
    Footer()
コード例 #25
0
def Team():
    nav = Navbar()
    footer = Footer()

    # Load team members
    with open("assets/team_members/core_team.yml") as f:
        core_members = yaml.load(f, Loader=yaml.FullLoader)
    num_core_members = len(core_members)

    with open("assets/team_members/associated_team.yml") as f:
        associated_members = yaml.load(f, Loader=yaml.FullLoader)
    num_associated_members = len(associated_members)

    with open("assets/team_members/faculty.yml") as f:
        faculty = yaml.load(f, Loader=yaml.FullLoader)
    num_faculty = len(faculty)

    # Single member pic
    def member_pic(member):
        return dbc.Col([
            dbc.Card([
                dbc.CardImg(src='assets/team_members/photos/%s' %
                            member['photo']),
                dbc.CardBody(
                    html.A(member['name'],
                           href=member['website'],
                           className="stretched-link team-name"),
                    className="team-card-body",
                ),
            ],
                     className="team-card h-100 w-100")
        ],
                       xs=12,
                       sm=6,
                       md=3,
                       lg=3,
                       xl=2,
                       style={'marginBottom': 7})

    # Table rows
    core_member_rows = \
        [
            dbc.Row(
                [
                    member_pic(core_members[0])
                ],
                justify="around"
            )
        ] + \
        [
            dbc.Row(
                [
                    member_pic(core_members[i]) for i in range(1,num_core_members)
                ],
                justify="around",
            )
        ]

    faculty_rows = \
        [
            dbc.Row(
                [
                    member_pic(faculty[i]) for i in range(num_faculty)
                ],
                justify="around",
            )
        ]

    associated_member_rows = \
        [
            dbc.Row(
                [
                    member_pic(associated_members[i]) for i in range(num_associated_members)
                ],
                justify="around",
            )
        ]

    body = dbc.Container(
            [
                dbc.Row(
                    [
                        dbc.Col(
                        [
                            html.H2("Our Team"),
                            html.P('Our team comprises passionate researchers in Operations Research \
                            and Analytics. We are eager to use our collective skills and create new \
                            tools that can help the scientific community fight against the pandemic.'                                                                                                     )
                        ]
                        )
                    ],
                    style={'marginBottom': 20}
                )
            ] + \
            [dbc.Row([dbc.Col([html.H3("Core Team Members")])],style={'marginBottom': 20})] + \
            core_member_rows + \
            [dbc.Row([dbc.Col([html.H3("Collaborating Faculty")])],style={'marginBottom': 20,'marginTop': 40})] + \
            faculty_rows + \
            [dbc.Row([dbc.Col([html.H3("Associated Team Members")])],style={'marginBottom': 20,'marginTop': 40})] + \
            associated_member_rows,
            className="page-body"
        )

    layout = html.Div([nav, body, footer], className="site")
    return layout
コード例 #26
0
    def initUI(self):
        self.sidebar = sidebar.Sidebar(self)
        self.sidebar.window.connect(self.getvalue)

        print("Dashboard")
        self.addDockWidget(Qt.LeftDockWidgetArea, self.sidebar)

        header = AppName("dashboard")
        footer = Footer()

        statslabel = QLabel("Statistics")
        statslabel.setStyleSheet("color: rgb(30, 45, 66);"
                                 'font: 75 16pt "MS Shell Dlg 2";')
        statslabel.setContentsMargins(20, 15, 0, 0)

        statistics = QHBoxLayout()

        dashboardsales = DashboardSales()
        dashboardorders = DashboardOrders()
        # dashboardprofits = DashboardProfits()

        statistics.addStretch()
        statistics.addWidget(dashboardsales)
        statistics.addStretch()
        statistics.addWidget(dashboardorders)
        statistics.addStretch()
        # statistics.addWidget(dashboardprofits)
        # statistics.addStretch()

        restaurantlabel = QLabel("Restaurant")
        restaurantlabel.setStyleSheet("color: rgb(30, 45, 66);"
                                      'font: 75 16pt "MS Shell Dlg 2";')
        restaurantlabel.setContentsMargins(20, 0, 0, 0)

        restaurantdetails = RestaurantDetails()

        layout = QVBoxLayout()

        layout.addWidget(header)
        layout.addWidget(statslabel)
        layout.addWidget(HLine())
        layout.addLayout(statistics)
        layout.addWidget(HLine())
        layout.addWidget(restaurantlabel)
        layout.addWidget(HLine())
        layout.addWidget(restaurantdetails)
        layout.addStretch()
        layout.addWidget(footer)

        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(0)

        centralWidget = QWidget()
        centralWidget.setLayout(layout)

        print("hello")

        self.setCentralWidget(centralWidget)
        self.setContentsMargins(0, 0, 0, 0)

        self.resize(1160, 605)
        self.setWindowTitle("Login")

        self.show()

        self.center()
コード例 #27
0
    def initUI(self):

        in_class = "tables"

        self.sidebar = sidebar.Sidebar(self)
        self.sidebar.window.connect(self.getvalue)

        self.addDockWidget(Qt.LeftDockWidgetArea, self.sidebar)

        header = AppName(in_class)
        footer = Footer()

        add_and_search = AddSearchFrame(in_class)
        add_and_search.add_button.clicked.connect(
            lambda: self.add_tables(in_class))
        add_and_search.search_button.clicked.connect(
            lambda: self.search_tables(add_and_search.search_box))

        self.table = QTableWidget()
        self.table.setColumnCount(4)
        # self.table.setStyleSheet("border: none")
        # self.table.setStyleSheet(
        #     "background-color: rgb(255, 255, 255);\n"
        #     'font: 10pt "MS Shell Dlg 2";\n'
        #     "color: rgb(30, 45, 66);"
        # )

        # self.table.setHorizontalHeaderItem(0, QTableWidgetItem("ID"))
        self.table.setHorizontalHeaderItem(0, QTableWidgetItem("Table Name"))
        self.table.setHorizontalHeaderItem(1, QTableWidgetItem("Covers"))
        self.table.setHorizontalHeaderItem(2, QTableWidgetItem("Edit"))
        self.table.setHorizontalHeaderItem(3, QTableWidgetItem("Delete"))

        # self.table.insertRow(self.table.rowCount())
        #
        # self.table.setItem(self.table.rowCount() - 1, 0, QTableWidgetItem("ID1"))
        # self.table.setItem(self.table.rowCount() - 1, 1, QTableWidgetItem("Name1"))
        # self.table.setItem(self.table.rowCount() - 1, 2, QTableWidgetItem("Job1"))
        # self.table.setItem(self.table.rowCount() - 1, 3, QTableWidgetItem("Joining Date1"))
        # self.table.setItem(self.table.rowCount() - 1, 4, QTableWidgetItem("Salary1"))
        # self.table.setItem(self.table.rowCount() - 1, 5, QTableWidgetItem("Bonus1"))
        # self.table.setItem(self.table.rowCount() - 1, 6, QTableWidgetItem("Total Salary1"))
        # self.table.setItem(self.table.rowCount() - 1, 7, QTableWidgetItem("Edit1"))
        # self.table.setItem(self.table.rowCount() - 1, 8, QTableWidgetItem("Delete1"))

        data = self.load_tables_data()
        print(data)

        for x in data:
            print(x)

        self.populate_table(data)

        layout = QVBoxLayout()

        layout.addWidget(header)
        layout.addWidget(add_and_search)
        layout.addWidget(self.table)
        # layout.addStretch()
        layout.addWidget(footer)

        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(0)

        centralWidget = QWidget()
        centralWidget.setLayout(layout)

        self.setCentralWidget(centralWidget)
        self.setContentsMargins(0, 0, 0, 0)

        # self.resize(800, 600)
        self.setWindowTitle("Login")
        self.resize(1160, 605)

        self.show()
        self.center()
コード例 #28
0
ファイル: flowables.py プロジェクト: NuCOS/autobasedoc
def create_footer(footerText, footerUrls):
    footer = Footer(footerMarginBottom=0.3, debug=False)
    defaultFooter = footer.footerBuild(copy.deepcopy(footerText), footerUrls)
    return defaultFooter
コード例 #29
0
### Dash
import dash
import flask
import dash_table
import dash_core_components as dcc
import dash_html_components as html
import dash_bootstrap_components as dbc

from navbar import Navbar
from footer import Footer

nav = Navbar()
footer = Footer()

body = dbc.Container(
    [
        dbc.Row(
            [
                dbc.Col([
                    html.H2("Epidemiological Model Documentation"),
                    html.P("""\
                        This page provides insights on a new epidemiological model developed by this team \
                        to provide estimates of the number of COVID-19 infections, hospitalizations, and \
                        deaths in all states of the United States. The model is based on the widely applied \
                        SEIR (Susceptible-Exposed-Infected-Recovered) modeling approach, which allocates every person to one of four states:
                       """),
                    dcc.Markdown('''
                  1. Susceptible: The general population that has not been infected and is not immune.
                  2. Exposed: People who are currently infected, but are not contagious and lie within the incubation period.
                  3. Infected: People who are currently infected and are contagious.
                  4. Recovered: People who recovered and are immune.
コード例 #30
0
ファイル: bundle.py プロジェクト: genexu/ptt-follower
class Bundle(object):
    """docstring for Bundle."""
    def __init__(self):
        super(Bundle, self).__init__()
        self.header = Header()
        self.body = Body()
        self.footer = Footer()
        self.status = NORMAL
        self.output = urwid.Frame(self.body.output,
                                  header=self.header.output,
                                  footer=self.footer.output,
                                  focus_part='body')

    def save_id(self, board_index, id):
        data = self.read_json_data()
        data['follow'][board_index]['id'].append(id)
        self.write_json_data(data)

    def save_board(self, board):
        board_data = {'board': board, 'id': []}
        data = self.read_json_data()
        data['follow'].append(board_data)
        self.write_json_data(data)

    def delete_id(self, board_index, id_index):
        data = self.read_json_data()
        data['follow'][board_index]['id'].pop(id_index)
        self.write_json_data(data)

    def delete_board(self, board_index):
        data = self.read_json_data()
        data['follow'].pop(board_index)
        self.write_json_data(data)

    def update_crawl_number_of_page(self, n):
        data = self.read_json_data()
        data['settings']['crawl_number_of_page'] = n
        self.write_json_data(data)

    def read_json_data(self):
        with open('data.json', 'r') as data_file:
            return json.load(data_file)

    def write_json_data(self, data):
        with open('data.json', 'w') as data_file:
            json.dump(data, data_file)

    def globle_input_listener(self, key):
        self.footer.input_response(repr(key))
        if repr(key) in ("'I'"):
            self.status = ADD_NEW_ID
            self.footer.add_new_id()
            self.output.focus_position = 'footer'

        if repr(key) in ("'B'"):
            self.status = ADD_NEW_BOARD
            self.footer.add_new_board()
            self.output.focus_position = 'footer'

        if repr(key) in ("'D'"):
            BOARD_LIST_INDEX = 0
            ID_LIST_INDEX = 1

            body_content_focus_postion = self.body.content.focus_position
            if body_content_focus_postion in (BOARD_LIST_INDEX, ID_LIST_INDEX):
                delete_item = self.body.content.focus
                delete_item_position = delete_item.focus_position

                if body_content_focus_postion == BOARD_LIST_INDEX:
                    self.status = DELETE_BOARD
                    self.footer.delete_board(delete_item_position)
                if body_content_focus_postion == ID_LIST_INDEX:
                    self.status = DELETE_ID
                    self.footer.delete_id(delete_item_position)

                self.output.focus_position = 'footer'

        if repr(key) in ("'N'"):
            self.status = UPDATE_CRAWL_NUMBER_OF_PAGE
            data = self.read_json_data()
            n = data['settings']['crawl_number_of_page']
            self.footer.update_crawl_number_of_page(n)
            self.output.focus_position = 'footer'

        if repr(key) in ("'R'"):
            self.body.post_list.update_posts()

        if repr(key) in ("'esc'"):
            if self.status in (ADD_NEW_ID, ADD_NEW_BOARD, DELETE_ID,
                               DELETE_BOARD, UPDATE_CRAWL_NUMBER_OF_PAGE):
                self.status = NORMAL
                self.footer.desc()
                self.output.focus_position = 'body'

        if repr(key) in ("'enter'"):
            if self.status in (ADD_NEW_ID):
                board_index = self.body.id_list.board_index
                new_id = self.footer.output.focus.edit_text
                self.save_id(board_index, new_id)
                self.body.add_new_id(new_id)

            if self.status in (ADD_NEW_BOARD):
                new_board = self.footer.output.focus.edit_text
                self.save_board(new_board)
                self.body.add_new_board(new_board)

            if self.status in (DELETE_ID):
                ans = self.footer.output.focus.edit_text
                if ans == 'y':
                    body_content_focus = self.body.content.focus
                    delete_item = self.body.content.focus
                    delete_item_position = delete_item.focus_position
                    board_index = self.body.id_list.board_index
                    self.delete_id(board_index, delete_item_position)
                    self.body.delete_id(delete_item_position)

            if self.status in (DELETE_BOARD):
                ans = self.footer.output.focus.edit_text
                if ans == 'y':
                    body_content_focus = self.body.content.focus
                    delete_item = self.body.content.focus
                    delete_item_position = delete_item.focus_position
                    self.delete_board(delete_item_position)
                    self.body.delete_board(delete_item_position)

            if self.status in (UPDATE_CRAWL_NUMBER_OF_PAGE):
                n = int(self.footer.output.focus.edit_text)
                if isinstance(n, int) and n > 0:
                    self.update_crawl_number_of_page(n)
                    self.body.update_crawl_number_of_page(n)

            if self.status in (ADD_NEW_ID, ADD_NEW_BOARD, DELETE_ID,
                               DELETE_BOARD, UPDATE_CRAWL_NUMBER_OF_PAGE):
                self.status = NORMAL
                self.footer.desc()
                self.output.focus_position = 'body'

        if repr(key) in ("'q'", "'Q'"):
            raise urwid.ExitMainLoop()